Background
Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of these primes. work in this area has resulted in the practical use of results from number theory and other branches of Mathematics
Once considered to be of only theoretical interest.
This problem involves the efficient computation of integer roots of numbers.
The Problem
Given an integer and an integer
You are to write a program that determines
, The positive
Root
P. In this problem, given such IntegersNAndP,PWill always be of the form
For an integer
K(This integer is what your program must find ).
The input
The input consists of a sequence of integer PairsNAndPWith each integer on a line by itself. For all such pairs
,
And there exists an integer
K, Such that
.
The output
For each integer pairNAndPThe value shoshould be printed, I. e., the number
KSuch that.
Sample Input
21632774357186184021382204544
Sample output
431234
I feel that there will be Precision Problems in double ..
# Include <stdio. h>
# Include <math. h>
Void main ()
{Double N, P;
Long left, right, mid;
While (scanf ("% lf", & N, & P )! = EOF)
{Left = 0; Right = 1000000000;
While (left <right)
{Mid = (left + right)/2;
If (POW (MID, n) = P) break;
If (POW (MID, n)> P) Right = mid;
If (POW (MID, n) <p) Left = mid;
}
Printf ("% d \ n", mid );
}
}