poj 2109 Power of Cryptography (double 精度)
题目:http://poj.org/problem?id=2109
题意:求一个整数k,使得k满足kn=p。
思路:exp()用来计算以e为底的x次方值,即ex值,然后将结果返回。log是自然对数,就是e为底计算的。换底公式 log<a>(b) = log<c>(b) / log<c>(a)。
float 的范围为-2^128 ~ +2^127,也即-3.40E+38 ~ +3.40E+38;
double 的范围为-2^1024 ~ +2^1023,也即-1.79E+308 ~ +1.79E+308
#include<stdio.h>
#include<math.h>
int main()
{
double n,p;
while(~scanf("%lf%lf",&n,&p))
{
printf("%g\n",pow(p,1.0/n));
}
return ;
}
这题正确的算法本来应该是贪心,二分+高精度。
见博客http://www.2cto.com/kf/201212/174001.html
poj 2109 Power of Cryptography (double 精度)的更多相关文章
- 贪心 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 Power of Cryptography 数学题 double和float精度和范围
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...
- POJ 2109 -- Power of Cryptography
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 26622 Accepted: ...
- poj 2109 Power of Cryptography
点击打开链接 Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16388 Ac ...
- POJ 2109 Power of Cryptography【高精度+二分 Or double水过~~】
题目链接: http://poj.org/problem?id=2109 参考: http://blog.csdn.net/code_pang/article/details/8263971 题意: ...
- POJ - 2109 Power of Cryptography(高精度log+二分)
Current work in cryptography involves (among other things) large prime numbers and computing powers ...
- POJ 2109 Power of Cryptography 大数,二分,泰勒定理 难度:2
import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger p,l,r,d ...
- 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 ...
- SOJ 1017 Power of Cryptography 库函数精度
Background Current work in cryptography involves (among other things) large prime numbers and comput ...
随机推荐
- Android Google购买PHP服务器端验证(订阅购买和一次性购买)
一.订阅购买验证 android端采用google service account进行校验 1.打开https://cloud.google.com/console创建一个project: 2.打开p ...
- android 软件开机自启动
安卓的很多功能实现方式都是“Don't call me, I'll call you back!”,开机启动就是其中之一 步骤: 1.首先建立一个BroadcastReceiver, 2.在他的onR ...
- Java实现mysql数据库备份
Runtime是一个与JVM运行时环境有关的类,这个类是Singleton的. Runtime.getRuntime()可以取得当前JVM的运行时环境,这也是在Java中唯一一个得到运行时环境的方法. ...
- Oracle中的USEREVN()
Oracle中的USEREVN() 1.USEREVN() 返回当前用户环境的信息,opt可以是: ENTRYID,SESSIONID,TERMINAL,ISDBA,LABLE,LANGUAGE,CL ...
- K2 Blackpearl 4.6.8 安装步骤详解
由于某些原因,我幼小的心灵受到了很大的创伤,倍感世态之炎凉,久久不能愈合,也因此很久没再接触K2 Blackpearl了.偶然来了兴趣,想整个K2的环境,闲暇之余了解其新功能,温故知新,也希望从中能讨 ...
- windows下编译php5.2.17这是闹哪样?
参考:http://demon.tw/software/compile-php-on-windows.html
- hibernate动态创建数据库表名几种方式
数据库中数据量很大, 但又不可以删除时同时又要优化程序检索数据时间. 答:方式有很多比如 创建数据库表分区,创建索引, 存储过程等; 我这里采用动态创建数据库表的方式. 完全可以在不创建表分区情况下实 ...
- SCRUM,一个采用迭代,增量方法来优化可预见控制风险
Scrum是一个用于开发和维持复杂产品的框架,是一个增量的,迭代的开发过程.在这个框架中,整个开发过程是由若干个短的迭代周期组成,一个短的迭代周期称为一个Sprint,每个Sprint的建议长度是2到 ...
- mybatis--面向接口编程
如果使用hiberante作为dao层,常用的方式是:定义一个dao层接口包(com.dao.service)然后在定义一个dao层接口实现包(com.dao.service.impl),这样定义结构 ...
- [转载]C#导入XLS数据到数据库
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...