[SWEA] 5688 세제곱근을 찾아라

Time Lapse :5min 3sec

5688.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>

int main(int argc, char** argv)
{
register int test_case;
register long long answer;
int T;
long long N;
setbuf(stdout, NULL);
scanf("%d", &T);
for (test_case = 1; test_case <= T; ++test_case){
scanf("%ld",&N);
for(answer = 1; answer <= N; answer++){
if(answer*answer*answer == N){
printf("#%d %ld\n",test_case ,answer);
break;
}
else if(answer*answer*answer > N) {
printf("#%d -1\n", test_case);
break;
}
}
}
return 0; //정상종료시 반드시 0을 리턴해야 합니다.
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/5688/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.