贪心 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: ...
随机推荐
- ios5之后arc的问题
原创: 自从ios5以后, apple官方引进了ARC (automaically reference count 自动索引计数) 这个新特性, 简单的说就是对象设置为nil(空引用)之后, 当自动索 ...
- FATAL: ActionView::Template::Error (application.css isn't precompiled):
iwangzheng.com tty:[0] jobs:[0] cwd:[/opt/logs/m]13:02 [root@a02.cmsapi$ tail thin\ server\ \(0.0.0. ...
- scp 命令
复制文件: (1)将本地文件拷贝到远程 scp 文件名 用户名@计算机IP或者计算机名称:远程路径 (2)从远程将文件拷回本地 ...
- 如何改变服务器的本地域名来访问本地服务器 而不用localhost或者127.0.0.1来访问
1. vim nginx.conf 如下: server { listen 80; server_name pma; ...
- c3p0数据库连接池
C3P0: 一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展.目前使用它的开源项目有Hibernate,Spring等. 默认情况下(即没有配置连接池的 ...
- Product of Array Exclude Itself
Given an integers array A. Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WI ...
- 对于sharepoint 的解决方案的实际说明
对于sharepoint 的解决方案 实际上就是cab的包 你把***.wsp改为***.cab我们就可以查看这个包中的所有内容了
- tesseract3.02识别验证码需要注意的问题
1.安装tesseract3.02后,在命令行里输入tesseract,看能否出现使用方法,不出现则是环境变量问题,可调整其顺序. 2.找到如下文件 C:\Python27\Lib\site-pack ...
- PHP负数判空
2014年11月6日 10:08:09 $a = -1; $b = '-1'; $c = empty($a); $d = empty($b); var_dump($c, $d); // bool(fa ...
- mysql show
1.show命令语法 SHOW {BINARY | MASTER} LOGS SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset, ...