当前位置:码农谷 > 算法与程序 > POJ 2109 Power of Cryptography:题目解答源码

POJ 2109 Power of Cryptography:题目解答源码

所属学科:C语言 - 位运算 难度: 关注度:300

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).

输入描述

The input consists of a sequence of integer pairs n and p with each integer on a line by itself. For all such pairs 1101 and there exists an integer k, 19 such that kn = p.

输出描述

For each integer pair n and p the value k should be printed, i.e., the number k such that k n =p.

程序源码

完整的源代码如下:

#define eps 0.0000000001
void init(), work();
double n, m, k;
int main()
{
    init();
    return 0;
}
void init()
{
    while(scanf("%lf %lf", &n, &m) != EOF)
        work();
}
void work()
{
    long long left, right, mid;
    left = 0;
    right = 1000000002;
    while(left + eps < right){
        mid = (left + right) / 2;

关注微信,获得更多免费资源
关于我们   |   免责声明   |   联系我们   |   网站地图   |   HR交流群   |   学生交流群   |   教师交流群

码农谷   版权所有 © 2015-2017   湘ICP备16018319号-1