题目地址: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的更多相关文章

  1. poj 2109 Power of Cryptography

    点击打开链接 Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16388   Ac ...

  2. POJ 2109 -- Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26622   Accepted: ...

  3. POJ 2109 Power of Cryptography 数学题 double和float精度和范围

    Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...

  4. poj 2109 Power of Cryptography (double 精度)

    题目:http://poj.org/problem?id=2109 题意:求一个整数k,使得k满足kn=p. 思路:exp()用来计算以e为底的x次方值,即ex值,然后将结果返回.log是自然对数,就 ...

  5. POJ - 2109 Power of Cryptography(高精度log+二分)

    Current work in cryptography involves (among other things) large prime numbers and computing powers ...

  6. POJ 2109 Power of Cryptography【高精度+二分 Or double水过~~】

    题目链接: http://poj.org/problem?id=2109 参考: http://blog.csdn.net/code_pang/article/details/8263971 题意: ...

  7. POJ 2109 Power of Cryptography 大数,二分,泰勒定理 难度:2

    import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger p,l,r,d ...

  8. 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 ...

  9. POJ 2109 :Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 18258   Accepted: ...

随机推荐

  1. shell kill掉含同一字符的关键字的进程

    如何kill掉进程名包含某个字符串的一批进程:kill -9 $(ps -ef|grep 进程名关键字|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') 观 ...

  2. 获取并设置ListView高度的方法

    01 public void setListViewHeightBasedOnChildren(ListView listView) {  02     ListAdapter listAdapter ...

  3. [Effective JavaScript 笔记] 第9条:始终声明局部变量

    如果忘记将变量声明为局部变量,该变量将会隐式地转变为全局变量 function swap(a,i,j){ temp=a[i]; a[i]=a[j]; a[j]=temp; } 尽管该程序没有使用var ...

  4. NGUI 学习笔记实战——制作商城UI界面

    http://www.cnblogs.com/chongxin/p/3876575.html Unity3D的uGUI听说最近4.6即将推出,但是目前NGUI等UI插件大行其道并且已经非常成熟,所以我 ...

  5. [官方说明] 为什么ES4要分成两阶段?

    从ES4第一个版本发布到现在,已经有段时间了,绝大多数坛友都已经适应了ES4所带来的新封装模式,但仍有部分新人和坛友对ES4的两阶段模式带有不解或曲解.本帖将就ES4的两阶段意义做出解释说明,希望更多 ...

  6. overflow-x和overflow-y其中一个设置为visible时的奇怪现象

    当overflow-x和overflow-y其中一个设置为visible时,如果另一个不是visible,那么它会被自动重置为auto 看看效果先: 第一次遇到这个问题时,我还以为是chrome的一个 ...

  7. [颓废] 改某人的WebGL light mapping demo并9xSSAA

    渲染图(4k) 链接: http://pan.baidu.com/s/1bnB4Wqz 密码: 8839 2px高斯模糊+立方缩小AA:  链接: http://pan.baidu.com/s/1mg ...

  8. Heap(堆)和stack(栈)有的区别是什么。

    java的内存分为两类,一类是栈内存,一类是堆内存.栈内存是指程序进入一个方法时,会为这个方法单独分配一块私属存储空间,用于存储这个方法内部的局部变量,当这个方法结束时,分配给这个方法的栈会释放,这个 ...

  9. 用几条shell命令快速去重10G数据

    试想一下,如果有10G数据,或者更多:怎么才能够快速地去重呢?你会说将数据导入到数据库(mysql等)进行去重,或者用java写个程序进行去重,或者用Hadoop进行处理.如果是大量的数据要写入数据库 ...

  10. BST树

    http://www.cnblogs.com/bizhu/archive/2012/08/19/2646328.html 4. 二叉查找树(BST) Technorati 标记: 二叉查找树,BST, ...