blob: 8f4f4d30bbc2a86732ce742318b9e8b08d88843d (
plain) (
tree)
|
|
#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;
}
|