poj 2109 Power of Cryptgraphy

1958 ワード

http://poj.org/problem?id=2109
 題意:kn = p,n,pをすでに知っていて、kを求めます。1<=n<=200,1<=p<10101, 1<=k<=109 
解析:私もびっくりしました。こんな大きなデータを見ました。   ディスクは一言でACができます。k=pow(p,1.0/n)を思い出しました。でも、k、p、nはdoubleでなければいけません。
なぜか調べてみました。
タイプ             長さ(bit)            有効な数字                    絶対値範囲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
他の人がこの問題は二点プラスの精度でいいと言っていますが、私もできません。無言です
                                                                               Power of Cryptgraphy
Time Limit: 1000 MS
 
メモリLimit: 30000 K
Total Submissions: 19419
 
Acceepted: 9804
Description
Currenent work in cryptgraphy involves large prinumbers and computings powers of numbers among thers prinemens.Work in this are has reulted in the practical use of rers of from nbers theoric and and therecordintch。
  This problem involves the efficient computation of integer roots of numbers.  Ginven integer n==1 and an integer p==1 you have to write a program that determines the n th positive root of p.In th is problem、given sutegers n and p、p will alys be of the form to to finth.prorectures。
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<10
101
 and there exists an integer k,1<=k<=109 such that kn = p.
Output
For each integer pair n and p the value k shoult be printed、i.e.the number k such that k n=p.
Sample Input
2 16
3 27
7 4357186184021382204544
Sample Output
4
3
1234