티스토리 뷰

반응형
시간 제한메모리 제한제출정답맞은 사람정답 비율
5 초256 MB18216214991.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

힌트














#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));

}

}



댓글

티스토리 방명록

최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday