博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj2109——Power of Cryptography
阅读量:2345 次
发布时间:2019-05-10

本文共 1397 字,大约阅读时间需要 4 分钟。

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

double能表示的范围为10^308范围的数,强制转化为int会WA…

#include 
#include
#include
#include
#include
//#include
#include
#include
#include
#include
#include
#define MAXN 1010#define mod 2012#define INF 0x3f3f3f3fusing namespace std;int main(){ ios::sync_with_stdio(false); double n,p; while(cin>>n>>p) { cout<

转载地址:http://gncvb.baihongyu.com/

你可能感兴趣的文章
是否可以在Python中将长行分成多行[重复]
查看>>
你什么时候使用Builder模式? [关闭]
查看>>
在jQuery中每5秒调用一次函数的最简单方法是什么? [重复]
查看>>
Angular 2+中的ngShow和ngHide等效于什么?
查看>>
如何将Java String转换为byte []?
查看>>
@Transactional注释在哪里?
查看>>
找不到Gradle DSL方法:'runProguard'
查看>>
AngularJS ngClass条件
查看>>
为什么需要在脚本文件的开头加上#!/ bin / bash?
查看>>
ReactJS-每次调用“ setState”时都会调用渲染吗?
查看>>
ng-if和ng-show / ng-hide有什么区别
查看>>
用Java复制文件的标准简洁方法?
查看>>
管理webpack中的jQuery插件依赖项
查看>>
删除可能不存在的文件的大多数pythonic方式
查看>>
如何在Eclipse中为Java文本编辑器更改字体大小?
查看>>
我们应该@Override接口的方法实现吗?
查看>>
ng-repeat定义次数而不是重复数组?
查看>>
选择语句以查找某些字段的重复项
查看>>
JavaScript ES6类中的私有属性
查看>>
默认情况下,如何以管理员身份运行Visual Studio?
查看>>