Power of Cryptography - poj 2109
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 20351 | Accepted: 10284 | 
Description
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
Output
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的更多相关文章
- 贪心 POJ 2109 Power of Cryptography
		题目地址:http://poj.org/problem?id=2109 /* 题意:k ^ n = p,求k 1. double + pow:因为double装得下p,k = pow (p, 1 / ... 
- 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 ... 
- poj 2109 Power of Cryptography
		点击打开链接 Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16388 Ac ... 
- POJ 2109 :Power of Cryptography
		Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 18258 Accepted: ... 
- POJ 2109 -- Power of Cryptography
		Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 26622 Accepted: ... 
- POJ   2109   Power of Cryptography   数学题   double和float精度和范围
		Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ... 
- Power of Cryptography(用double的泰勒公式可行分析)
		Power of Cryptography Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ... 
- [POJ2109]Power of Cryptography
		[POJ2109]Power of Cryptography 试题描述 Current work in cryptography involves (among other things) large ... 
- UVA 113 Power of Cryptography (数学)
		Power of Cryptography Background Current work in cryptography involves (among other things) large p ... 
随机推荐
- [CF232E]Quick Tortoise
			题目大意: 给你一个$n\times m(n,m\leq 500)$的格子,有一些是障碍物.从一个格子出发只能向下或向右走,有$q$组询问,每次询问从一个点是否能够到达另一个点. 思路: 分治. 两点 ... 
- lua的table.sort
			local aa = {{a=11},{a=44},{a=33},{a=2} } table.sort(aa,function(a,b) return a.a>b.a end) for k, v ... 
- Orchard EventBus 事件总线及 IEventHandler作用
			事件总线接口定义: public interface IEventBus : IDependency { IEnumerable Notify(string messageName, IDiction ... 
- java内存缓存,节省内存
			缓存的对象 这个问题就是我们上面提到的极端情况,在Java中,会对-128到127的Integer对象进行缓存,当创建新的Integer对象时,如果符合这个这个范围,并且已有存在的相同值的对象,则返回 ... 
- ocmock
- ESB 12种跑法
			ESB 12种跑法 请求响应: MQ-MQ MQ-Webservice Webservice-MQ Webservice-Webservi ... 
- Shell--变量的显示与设置、环境变量、语系变量
			1.变量的显示与设置:echo,unsetecho:显示一段文字,也可以读出变量内容并打印出来 格式echo $变量或者echo ${变量}语 法:echo [-neE][字符串]或 echo [- ... 
- 2017.5.1 java动态代理总结
			参考来自:http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html 1.代理模式 代理类和委托类有相同接口. 代理类负责为委托类:预处理消 ... 
- spring自动装配(No qualifying bean )
			No qualifying bean of type [com.wfj.service.cms.main.ChannelMng] found for dependency: expected at l ... 
- Android 软键盘的监听(监听高度,是否显示)
			Android官方本身没有提供一共好的方法来对软键盘进行监听,但我们实际应用时.非常多地方都须要针对软键盘来对UI进行一些优化. 下面是整理出来的一个不错的方法.大家能够使用. public clas ... 
