summaryrefslogtreecommitdiffstats
path: root/inf/priprave/dn/1b.c
diff options
context:
space:
mode:
Diffstat (limited to 'inf/priprave/dn/1b.c')
-rw-r--r--inf/priprave/dn/1b.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/inf/priprave/dn/1b.c b/inf/priprave/dn/1b.c
new file mode 100644
index 0000000..8f4f4d3
--- /dev/null
+++ b/inf/priprave/dn/1b.c
@@ -0,0 +1,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;
+}