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 ...
随机推荐
- JAVA基础加强(张孝祥)_类加载器、分析代理类的作用与原理及AOP概念、分析JVM动态生成的类、实现类似Spring的可配置的AOP框架
1.类加载器 ·简要介绍什么是类加载器,和类加载器的作用 ·Java虚拟机中可以安装多个类加载器,系统默认三个主要类加载器,每个类负责加载特定位置的类:BootStrap,ExtClassLoader ...
- Jenkins配置Java项目1(Java+Maven+Tomcat+SVN/Git)
先收集几个网址,后续再自己动手过一遍 http://www.cnblogs.com/leefreeman/p/4211530.html http://www.cnblogs.com/sunzhench ...
- delphi crc校验函数
function CalCRC16(AData: array of Byte; AStart, AEnd: Integer): string;const GENP=$8408; //多项式公式X1 ...
- TQ2440平台上LCD驱动的移植
参考: http://liu1227787871.blog.163.com/blog/static/205363197201242393031250/ http://blog.csdn.net/cum ...
- squid 三种代理实验
squid 软件既可以做代理,也可以做实现缓存加速,大大降低服务器的I/O.. 1.其中squid代理分为三种,正向代理.透明代理.反向代理. (1)squid正向代理和squid透明代理都位客户端: ...
- 常见java异常
1. java.lang.NullPointerException(空指针异常) 调用了未经初始化的对象或者是不存在的对象 经常出现在创建图片,调用数组这些操作中,比如图片未经初始化,或者图片创建时 ...
- Git的微操作
合并分支代码,简单操作: 1.切换到master主干代码 2.到git repositories 视图,点击需要合并的分支,例如v1.1.9 点击merge 进行合并 3.然后push to Upst ...
- ecshop_商品描述远程图片自动本地化插件
解压缩文件,覆盖 ecshop 的 \includes\fckeditor文件夹. 这样在后台添加商品的商品详细描述,编辑器最后一个按钮就是自动下载 远程图片到你的网站空间,这样可防止对方网站图片失效 ...
- MySql中文乱码问题(3)
MySql的client是在dos界面上,然而dos界面默认的字符集编码方式是:GBK (1).MySql字符转换原理图 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi ...
- Linux下xargs命令详解及xargs与管道的区别
在工作中经常会接触到xargs命令,特别是在别人写的脚本里面也经常会遇到,但是却很容易与管道搞混淆,本篇会详细讲解到底什么是xargs命令,为什么要用xargs命令以及与管道的区别.为什么要用xarg ...