poj2109

Power of Cryptography

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 20371   Accepted: 10293

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 should 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

Source

México and Central America 2004

double   10的308次幂到负的308

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    double n,m;
    while(cin>>n>>m)
    {
        n=(double)pow(m,1/n);
        cout<<n<<endl;
    }
    return 0;
}
时间: 2024-10-10 00:03:44

poj2109的相关文章

poj2109 Power of Cryptography(数学题)

题目链接:http://poj.org/problem?id=2109 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 num

poj2109(Power of Cryptography)

神水. 求n=log(k p)-> k=pow(p,1/n). G++和C++输出不同,编译器原因. 代码: 1 #include<cstdio> 2 #include<cmath> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 7 using namespace std; 8 9 int main() 10 { 11 double n,p; 12 whil

POJ2109——Power of Cryptography

Power of Cryptography DescriptionCurrent 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

poj2109 这货是大数么

你以为它是大数,但实际上它不是 我觉得这应该是种可正常的姿势了 import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger p,l,r,div; static int n; public static int cmp(BigInteger mid){ BigInteger sum=mid.pow(n); return sum.compareTo(p); } public

POJ2109 高精度(含大数开方)+二分

1 高精度(含大数开方)+二分 一个技巧和三点注意: 技巧:假设k^n=p;(k的n次方),那么p的位数/n得到的是k的位数!例如:n=7,p=4357186184021382204544,p的位数为22,用22/7的结果向上取整,得到4,即为k的位数,也就是说k的取值范围是1000~9999.(引自code_pang)不利用这一点,高精度+直接二分,也会超时.用这一个技巧合理缩小二分的范围. 注意:看code的main中的注释. (二分思想不熟练,因为二分算法很高效,所以一定要暴力点直接确定l

高进度水题(POJ2109)

题目链接:http://poj.org/problem?id=2109 double 可以虽然可以表示10^-307~~~10^208,但是精确度只有16位,这个题有bug. #include <stdio.h> #include <cmath> using namespace std; int main() { double n,p; while(scanf("%lf%lf",&n,&p)!=EOF) { printf("%.0f\n

poj2109 【贪心】

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 onc

acm常见算法及例题

转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法

ACM算法总结及刷题参考

参考:http://bbs.byr.cn/#!article/ACM_ICPC/11777 OJ上的一些水题(可用来练手和增加自信)(poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094) 初期: 一.基本算法: (1)枚举. (poj1753,poj2965)    (2)贪心(poj1328,poj2109,poj2586)    (3)递归和分治法.     (4)递推.     (5)构造法.(po