Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 20351   Accepted: 10284

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
注:这题分类是贪心算法,但是看了discuss之后竟然发现用double一句可以AC,也是醉了
k^n=p
n=log(p)/log(k)
log(k)=log(p)/n
2^log(k)=2^(log(p)/n)
k=p^(1/n)
附:float,double,long 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
 #include<iostream>
#include<math.h>
using namespace std; int main()
{
double n,p;
while(cin>>n>>p)
cout<<pow(p,1.0/n)<<endl;
return ;
}

Power of Cryptography - poj 2109的更多相关文章

  1. 贪心 POJ 2109 Power of Cryptography

    题目地址:http://poj.org/problem?id=2109 /* 题意:k ^ n = p,求k 1. double + pow:因为double装得下p,k = pow (p, 1 / ...

  2. Poj 2109 / OpenJudge 2109 Power of Cryptography

    1.Link: http://poj.org/problem?id=2109 http://bailian.openjudge.cn/practice/2109/ 2.Content: Power o ...

  3. poj 2109 Power of Cryptography

    点击打开链接 Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16388   Ac ...

  4. POJ 2109 :Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 18258   Accepted: ...

  5. POJ 2109 -- Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26622   Accepted: ...

  6. POJ 2109 Power of Cryptography 数学题 double和float精度和范围

    Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...

  7. Power of Cryptography(用double的泰勒公式可行分析)

    Power of Cryptography Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

  8. [POJ2109]Power of Cryptography

    [POJ2109]Power of Cryptography 试题描述 Current work in cryptography involves (among other things) large ...

  9. UVA 113 Power of Cryptography (数学)

    Power of Cryptography  Background Current work in cryptography involves (among other things) large p ...

随机推荐

  1. (转)stage 3d or unity 3d

    这个是这样子的.stage3d如果不使用flascc的话,性能会卡在as上面.你没卡是因为你用的效果还不够高级.往深了走的高端应用就是卡as性能上.这不是你代码能优化了的.我们后来都改用flascc写 ...

  2. 教程:基于Spring快速开发电子邮件发送功能

    在Spring框架的spring-context-support.jar中有对电子邮件发送功能的封装: 基于Spring开发简单省事,而且更稳定.需要mail.jar包支持 @Component pu ...

  3. webstorm编辑器设置为vim的方法

    首先有这个插件,其设置如下,选中即可 打开和关闭方法: https://www.jetbrains.com/help/webstorm/vim-emulation.html https://plugi ...

  4. sqlserver中常用的四个选项(NOCOUNT/ANSI_NULLS/QUOTED_IDENTIFIER/ XACT_ABORT)

    1 NOCOUNT选项 当 SET NOCOUNT 为 ON 时,不返回计数.当 SET NOCOUNT 为 OFF 时,返回计数. eg: if object_id(N'table_test',N' ...

  5. CvArr、Mat、CvMat、IplImage、BYTE转换

    一.Mat类型:矩阵类型,Matrix.     在openCV中.Mat是一个多维的密集数据数组. 能够用来处理向量和矩阵.图像.直方图等等常见的多维数据.     Mat有3个重要的方法:     ...

  6. [Algorithms] Classify Mystery Items with the K-Nearest Neighbors Algorithm in JavaScript

    The k-nearest neighbors algorithm is used for classification of unknown items and involves calculati ...

  7. EffectiveJava(14)在公有类中使用访问方法而非公有域

    1.公有类永远都不应该暴露可变的域.如果域是不可变的,暴露公有类的危害就要小一些. 但是,有时候需要用包级私有的或者私有的嵌套类来暴露域,无论这个类是否可变 2.如果公有类暴露了它的访问域,要想在将来 ...

  8. 使用Jenkins+Calabash+Cocoapods搭建iOS持续集成环境

    使用jenkins+calabash+cocoapods搭建ios持续集成环境 持续集成 持续集成到底是什么呢?依据敏捷大师Martin Fowler的定义: 持续集成是一种软件开发实践. 在持续集成 ...

  9. 尝试一下markdown

    尝试一下markdown 简单介绍以下几个宏: __VA_ARGS__是一个可变参数的宏,这个可变参数的宏是新的C99规范中新增的,目前似乎只有gcc支持(VC6.0的编译器不支持).宏前面加上##的 ...

  10. 自己如何正确获取MYSQL的ADO连接字符串

    1.下载安装MYSQL的ODBC数据库驱动程序(mysql-connector-odbc-5.3.4-win32.msi或者mysql-connector-odbc-5.3.4-winx64.msi) ...