博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2109 -- Power of Cryptography
阅读量:7100 次
发布时间:2019-06-28

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

Power of Cryptography
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 17945   Accepted: 9053

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 n
th. 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<10
101 and there exists an integer k, 1<=k<=10
9 such that k
n = 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 163 277 4357186184021382204544

Sample Output

431234 用c++交ac ,g++交wrong,不知为何。
/*====================================================================== *           Author :   kevin *         Filename :   PowerOfCryptography.cpp *       Creat time :   2014-05-14 19:08 *      Description :========================================================================*/#include 
#include
#include
#include
#include
#include
#define clr(a,b) memset(a,b,sizeof(a))#define M using namespace std;int main(int argc,char *argv[]){ double n,p; while(scanf("%lf%lf",&n,&p)!=EOF){ printf("%.0lf\n",pow(p,1/n)); } return 0;}

 

转载于:https://www.cnblogs.com/ubuntu-kevin/p/3728533.html

你可能感兴趣的文章
学习springBoot(2)常用注解
查看>>
Java Servlet GZip Servlet Filter 详解
查看>>
加快发展数字经济,GMQ致力搭建更专业全面的数字资产交易
查看>>
如何像程序员一样思考——解决问题的经验
查看>>
redux源码阅读
查看>>
好程序员web前端分享JS引擎的执行机制
查看>>
为何 DevOps 是如今最重要的技术策略
查看>>
HttpServletRequest使用&乱码处理&请求转发
查看>>
IDEA Plugin 开发探索
查看>>
Mac 下编译 Hadoop
查看>>
JS中的变量
查看>>
laravel学习资源
查看>>
ELSE 技术周刊(2017.11.20期)
查看>>
js公式
查看>>
多线程相关
查看>>
如何对第一个Vue.js组件进行单元测试 (上)
查看>>
Tomcat的Server.xml配置详解
查看>>
给出指定值,获取数组中和相同的元素并输出
查看>>
Android APT快速教程
查看>>
【译】2019,跟上 AI 的脚步:AI 和 ML 接下来会发生什么重要的事?
查看>>