题目地址: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. Unity游戏开发之“屏幕截图”

    原地址:http://sygame.lofter.com/post/117105_791680 在unity游戏开发中,可能会遇到在游戏中截屏的效果.这儿提供两种截屏方法.(方法二提供显示截图缩略图代 ...

  2. ajax页面排序的序号问题

    文章是从我的个人博客上粘贴过来的, 大家也可以访问我的主页 www.iwangzheng.com 目前使用的ajax排序是这样的. 每个table , 都要这样声明 ( table 中必须有2个属性: ...

  3. 对原型prototype的详解

    刚开始接触对象原型时大脑就开始起义了,脑子就转不灵清了.就感觉怎么着这个概念就是灌输不进去,俗称断路.后面找了很多资料,最主要的还是要借助于<JavaScript语言精髓>这本书,让我对这 ...

  4. Java常用排序算法+程序员必须掌握的8大排序算法

    概述 排序有内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存. 我们这里说说八大排序就是内部排序. 当n较大, ...

  5. 基础知识《二》java的基本类型

    一.java基本数据类型 Java基本类型共有八种,基本类型可以分为三类,字符类型char,布尔类型boolean以及数值类型byte.short.int.long.float.double.数值类型 ...

  6. 【leetcode】Longest Consecutive Sequence

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

  7. object-c 基本数据类型

    1.基本数据类型   int  float  double  char   布尔类型   枚举类型 2.对象类型和id类型  就是类类型或协议所声明的指针类型.  id类型可以表示任何类型,一般只表示 ...

  8. iOS 关于Layer的疑问

    很久很久以前,就对ios的Layer十分的不解,学习了android后,打算通过android中的相关实现,分析一下ios中layer的作用,结果没有找到android中的对应的内容!十分让人郁闷.于 ...

  9. 好玩儿的expect

    前言 1> 借鉴里面的应用思想,使用断言提高代码的健壮性及维护性 2> 实现方式——不采用直接嵌入expect的方式,统一进行重写(提取常用断言方法,重新构造API) 官网介绍 https ...

  10. C++实现大数据乘法

    结构体定义与封装 struct bigdatacom { private : ]; ]; public : void init(const char *str1,const char *str2) { ...