blob: 8f4f4d30bbc2a86732ce742318b9e8b08d88843d (
plain) (
blame)
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
33
34
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void) {
int a, b, n;
char buf[128];
char * cp = buf;
fgets(buf, 128, stdin);
buf[128] = '\0';
a = strtol(cp, &cp, 10);
if (!cp)
return 1;
cp++;
b = strtoll(cp, &cp, 10);
if (!cp)
return 2;
n = strtol(cp, &cp, 10);
if (a == 0) {
puts("5\n");
return 0;
}
if (b%a) {
puts("No solution\n");
return 0;
}
b /= a;
for (int i = -1000; i <= 1000; i++) /* mam 2 sekundi */
if (pow(i, n) == b) {
printf("%d\n", i);
return 0;
}
puts("No solution\n");
return 0;
}
|