티스토리 뷰
Polyhedra 성공
시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 | 256 MB | 182 | 162 | 149 | 91.975% |
문제
Given a sphere, you can slice through the surface of the sphere to make different convex polyhedra. All of these convex polyhedra have the Euler characteristic which can be defined as follows:
x = V − E + F = 2
where V represents the number of vertices, E the number of edges and F the number of faces on a convex polyhedron.
입력
Input begins with a line with a single integer T, 1 ≤ T ≤ 100, denoting the number of test cases. Each test case consists of a single line with two space-separated integers V and E (4 ≤ V, E ≤ 100), representing the number of vertices and edges respectively of the convex polyhedron.
출력
For each test case, print on a single line the number of faces in the defined polyhedron.
예제 입력
2 8 12 4 6
예제 출력
6 4
힌트
출처
ACM-ICPC > Regionals > North America > Pacific Northwest Regional > 2014 Pacific Northwest Region Programming Contest Division 2 M번
#include <stdio.h>
#include <math.h>
int main(){
int N, i, V, E, F;
scanf("%d", &N);
for(i = 0; i < N; i++){
scanf("%d %d", &V, &E);
F = V - E - 2;
printf("%d\n", abs(F));
}
}
'C, C++ > Baekjoon Online Judge' 카테고리의 다른 글
Baekjoon 백준 1110번 더하기 사이클 (0) | 2016.05.06 |
---|---|
Baekjoon 백준 5585번 거스름돈 (0) | 2016.05.06 |
Baekjoon 백준 5597번 과제 안 내신분..? (0) | 2016.05.05 |
Baekjoon 백준 2562번 최대값 (0) | 2016.05.04 |
Baekjoon 백준 10171번 고양이 (0) | 2016.05.04 |
티스토리 방명록
- Total
- Today
- Yesterday
Contact: j0n9m1n1@gmail.com