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 ...
随机推荐
- BroadcastReceiver
BroadcastReceiver 广播接受者 Android中, Broadcast是一种数据传递的方式/通信方式. Brodadcast 是Android 系统组件之一 广播的特性 1. 由一个发 ...
- Cassandra1.2文档学习(11)—— 删除数据
参考文档:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/dml/dml_about_ ...
- Python字符串内建处理函数
#coding=utf-8 __author__ = 'Administrator' # 字符串处理函数 s1 = "study python string function , I lov ...
- java-----基本数据类型包装类
目的:为了方便操作基本数据类型值,将其封装为对象,在对象定义了属性和行为,丰富了改数据的操作,用于描述该对象的类也就成为基本数据类型对象包装类. 例如:int类型的取值范围:Integer------ ...
- 再次学习C++类之构造函数
学习C++类,首先要说C中的结构体,虽然C++类扩展了C中的结构体,可以添加成员函数,但他们是有区别的.在结构体中,成员变量.成员函数都是公有的,而类中,一般是成员变量是私有的,成员函数是公有的,私有 ...
- NodeJs环境部署
node cli.js install npm -gf npm install express -gd
- java 构造函数
1.public className(){}. 2.名称与类名相同,无返回值,无返回类型,void也不行.(就是上边的形式,除了可以有参数). 3.有0个或多个参数. 4.每个类都至少有一个const ...
- Android模拟神器Genymotion eclipse插件安装问题出解决
我之前一直是打开eclipse之前直接运行Genymotion模拟器就可以连接到adb了,非常方便,但最近突然想来装个eclipse的Genymotion插件玩玩,安装时居然出错了,于是不折腾好心里不 ...
- C# send mail with outlook and word mailmerge
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document_members(v=office.15). ...
- submit与button区别提交区别
提交表单时使用submit会自动提交form表单数据, 如果使用jquery的form表单插件时需要将提交按钮改为button时$("#表单id").ajaxSubmit({}); ...