贪心 POJ 2109 Power of Cryptography
题目地址:http://poj.org/problem?id=2109
/*
题意:k ^ n = p,求k
1. double + pow:因为double装得下p,k = pow (p, 1 / n);
基础知识: 类型 长度 (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
2. 二分查找:和1类似
3. 取对数:n*ln(k)=ln(p) ln(k)=ln(p)/n k=exp(ln(p)/n)
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <vector>
using namespace std; const int MAXN = 1e6 + ;
const int INF = 0x3f3f3f3f; int main(void) //POJ 2109 Power of Cryptography
{
//freopen ("D.in", "r", stdin);
double n, p, k; while (~scanf ("%lf%lf", &n, &p))
{
printf ("%.0f\n", pow (p, / n));
} return ;
} /*
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std; void BinarySearch(int l, int r, double n, double p)
{
int mid; while (l <= r)
{
mid = l + (r - l) / 2;
double tmp = pow (mid, n);
if (tmp == p)
{
printf ("%d\n", mid); return ;
}
else if (tmp < p) l = mid + 1;
else r = mid - 1;
}
} int main(void)
{
//freopen ("D.in", "r", stdin); double n, p; while (~scanf ("%lf%lf", &n, &p))
{
BinarySearch (1, 1e9, n, p);
} return 0;
}
*/ /*
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std; int main(void) //POJ 2109 Power of Cryptography
{
//freopen ("D.in", "r", stdin); double n, p; while (~scanf ("%lf%lf", &n, &p))
{
printf ("%.0f\n", exp (log (p) / n));
} return 0;
}
*/
贪心 POJ 2109 Power of Cryptography的更多相关文章
- 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: 26622 Accepted: ...
- 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 (double 精度)
题目:http://poj.org/problem?id=2109 题意:求一个整数k,使得k满足kn=p. 思路:exp()用来计算以e为底的x次方值,即ex值,然后将结果返回.log是自然对数,就 ...
- 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【高精度+二分 Or double水过~~】
题目链接: http://poj.org/problem?id=2109 参考: http://blog.csdn.net/code_pang/article/details/8263971 题意: ...
- 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 ...
- POJ 2109 :Power of Cryptography
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 18258 Accepted: ...
随机推荐
- Who Gets the Most Candies?(线段树 + 反素数 )
Who Gets the Most Candies? Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%I64d &am ...
- 关于Eclipse部署openfire3.8.2源码的体会
因为公司要做人际银行的一个项目需要openfire(服务器)+asmack(客户端),所以需要对消息的推送及消息发送知识的积累.所以需要研究xmpp,以前不是很了解这个技术,现在需要学习.首先就得部署 ...
- [OpenJudge 3061]Flip The Card
[OpenJudge 3061]Flip The Card 试题描述 There are N× Ncards, which form an N× Nmatrix. The cards can be p ...
- 删除右键ATI CATALYST(R) Control Center的方法
http://share.weiyun.com/c47530d3e44ea15b606d4ba6f1b00a28
- /var/lock/subsys作用
转自: http://sunxiaqw.blog.163.com/blog/static/9906543820111184422807/ 关于/var/lock/subsys目录 总的来说,系统关闭的 ...
- 【原创】sql:慎用【数字字段1 - 数字字段2】这样的sql(10-null = null)mysql
如果只有一个表的情况下 a表: id num1,num2 1 10 5 2 10 0 3 20 0 select id, num1,num2,num1 - num2 AS subNum from a; ...
- C++ traits
[本文链接] http://www.cnblogs.com/hellogiser/p/cplusplus-traits.html [分析] 什么是traits?其实它并不是一个新的概念,上个世纪90年 ...
- php-fpm启动
2014年6月30日 11:52:17 遇到一个问题,安装了redis.so后无论怎么重启nginx 还是 php-fpm都无法加载redis 最后发现重启php-fpm的参数弄错了 要这样: ./p ...
- Java中泛型在集合框架中的应用
泛型是Java中的一个重要概念,上一篇文章我们说过,当元素存入集合时,集合会将元素转换为Object类型存储,当取出时也是按照Object取出的,所以用get方法取出时,我们会进行强制类型转换,并且通 ...
- Windows 8操作技巧之快捷键大全
Windows 8操作系统发布之后,因为其新颖的界面和对触屏友好的设计,使许多长期使用Windows系统的用户,也觉得一时难以适应,一些操作方式也不知道如何去实现.在Windows系统中,快捷键无疑是 ...