贪心 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: ...
随机推荐
- Android开源项目第二篇——工具库篇
本文为那些不错的Android开源项目第二篇——开发工具库篇,**主要介绍常用的开发库,包括依赖注入框架.图片缓存.网络相关.数据库ORM建模.Android公共库.Android 高版本向低版本兼容 ...
- NGUI 图集生成 图片Sprite 有撕裂边的问题
修改 Dimensions 的 X 和 Y值进行调整. 在生成图集时 选择Padding 设置1以上 应该不会出现这个问题.
- Maven使用常见问题整理
Maven使用常见问题整理 1.更新eclipse的classpath加入新依赖 1.在dependencyManagement里面加入包括版本在内的依赖信息,如: <dependenc ...
- Delphi10 安装Graphics32
一.下载Graphics安装包 官网:www.graphics32.org 下载地址:http://sourceforge.net/projects/graphics32/files/graphics ...
- django-cms 代码研究(六)plugin的深入分析
示例代码: https://github.com/divio/djangocms-picture 以上一个图片的插件,安装后可在页面中添加图片,效果如下图: 以此为切入点,分析plugin的逻辑: 分 ...
- 《ASP.NET1200例》<ItemTemplate>标签在html里面有什么具体的作用
严格的来说 <ItemTemplate> 在html中无意义,他只是针对诸如 Repeater.DataList.GridView中的一个模板 至于里面的含义,你可以这样想,既然Repea ...
- Java for LeetCode 037 Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- git revert 用法
git revert 撤销 某次操作,此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交 * git revert HEAD ...
- java call sap
1.下载需要的jar,windows用dll,linux用so win下载地址 linux下载地址 win下载地址new 2.环境: windows -> sapjco3.dll放到wi ...
- cjb
输入216.194.70.6 ,进入到是cjb.net的主页,并不是shell.cjb.net ,进入主页后点击shell,就进不去了 分析:shell.cjb.net被DNS污染了 解法:hosts ...