I don't know if it's greedy... Students are greedy.
Note: The range of data types is unknown;
Original question link: http://poj.org/problem? Id = 2109
Power of cryptography
Time limit:1000 ms |
|
Memory limit:30000 K |
Total submissions:13983 |
|
Accepted:7136 |
Description
Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers among 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 only of theoretical interest.
This problem involves the efficient computation of integer roots of numbers.
Given an integer n> = 1 and an integer p> = 1 you have to write a program that determines the n th Positive Root of P. in this problem, given such integers N and P, P will always be of the form k to the nth. power, for an integer k (this integer is
What your program must find ).
Input
The input consists of a sequence of integer pairs N and P with each integer on a line by itself. for all such pairs 1 <= n <= 200, 1 <= P <10101 and there exists an integer k, 1 <= k <= 109 such that kN = P.
Output
For each integer pair N and P the value K shoshould be printed, I. e., the number k such that k N = P.
Sample Input
2 163 277 4357186184021382204544
Sample output
431234
Source
Mé xico and Central America 2004 data types range: From kb blog: http://www.cnblogs.com/kuangbin/archive/2011/07/23/2115001.html
Unsigned int 0 ~ 4294967295
Int 2147483648 ~ 2147483647
Unsigned long 0 ~ 4294967295
Long 2147483648 ~ 2147483647
Maximum Value of long: 9223372036854775807
The minimum value of long:-9223372036854775808.
Maximum Value of unsigned long: 1844674407370955161
Maximum Value of _ int64: 9223372036854775807
_ Int64 minimum:-9223372036854775808
Maximum unsigned _ int64: 18446744073709551615
Float 32 6 ~ 7 10 ^ (-37 )~ 10 ^ 38
Double 64 15 ~ 16 10 ^ (-307 )~ 10 ^ 308
Long Double 128 18 ~ 19 10 ^ (-4931 )~ 10 ^ 4932
//Accepted212K0MSC++212B2012-09-18 20:47:04#include<cstdio>#include<cmath>int main(){ double n,p; double ans; while(scanf("%lf%lf",&n,&p)!=EOF) { ans=pow(p,1/n); printf("%.0lf\n",ans); } return 0;}