-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathro.c
More file actions
32 lines (29 loc) · 688 Bytes
/
Copy pathro.c
File metadata and controls
32 lines (29 loc) · 688 Bytes
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
26
27
28
29
30
31
32
#include<stdio.h>
#include<math.h>
#include<string.h>
int FindRoot(int M, int N) {
if (N == 0 || N == 1 || N > MAXN) {return -1;}
if (M == 0 || M > MAXM) {return -1;}
float answer = pow(M,1./N);
int isInt = (int)answer;
if(answer == isInt) {
return isInt;
}
else {
return -1;
}
int main(int argc, char *argv[]) {
char * line = NULL;
int M,N,i;
int len = 0;
int tests = 0;
char buff[3];
int buffer;
scanf ("%d", &tests);
for(i=0; i< tests; i++) {
scanf ("%d", &N);
scanf ("%d", &M);
printf("%d\n",FindRoot(M, N));
}
return 1;
}