POJ:2109-Power of Cryptography(关于double的误差)
Power of Cryptography
Time Limit: 1000MS Memory Limit: 30000K
Description
Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers among these primes. Work in this area has resulted in the practical use of results from number theory and other branches of mathematics once considered to be only of theoretical interest.
This problem involves the efficient computation of integer roots of numbers.
Given an integer n>=1 and an integer p>= 1 you have to write a program that determines the n th positive root of p. In this problem, given such integers n and p, p will always be of the form k to the nth. power, for an integer k (this integer is what your program must find).
Input
The input consists of a sequence of integer pairs n and p with each integer on a line by itself. For all such pairs 1<=n<= 200, 1<=p<10101 and there exists an integer k, 1<=k<=109 such that kn = p.
Output
For each integer pair n and p the value k should be printed, i.e., the number k such that k n =p.
Sample Input
2 16
3 27
7 4357186184021382204544
Sample Output
4
3
1234
- 刚看到的时候还是想用大数硬怼,但是明显不可能啊。看了一下网上别人的代码,发现代码很简单。但是关于double的误差问题都没怎么说清楚,想关注double详情的可以看看大神的分析:http://blog.csdn.net/synapse7/article/details/11672691
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double a,b;
while(cin>>a>>b)
{
cout<<pow(b,1.0/a)<<endl;
}
return 0;
}
POJ:2109-Power of Cryptography(关于double的误差)的更多相关文章
- 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
题目地址:http://poj.org/problem?id=2109 /* 题意:k ^ n = p,求k 1. double + pow:因为double装得下p,k = pow (p, 1 / ...
- 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 精度)
题目:http://poj.org/problem?id=2109 题意:求一个整数k,使得k满足kn=p. 思路:exp()用来计算以e为底的x次方值,即ex值,然后将结果返回.log是自然对数,就 ...
- 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(高精度log+二分)
Current work in cryptography involves (among other things) large prime numbers and computing powers ...
- 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: ...
随机推荐
- RabbitMQ使用教程(二)RabbitMQ用户管理,角色管理及权限设置
上一篇博客 RabbitMQ使用教程(一)RabbitMQ环境安装配置及Hello World示例 中,我们成功的安装好了RabbitMQ环境,并通过一个Java客户端示例了解了用生产者来发布消息,用 ...
- 渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程(下)
关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/08/12/es-code03/ 前提 上篇文章写完了 ES 流程启动的一部分,main 方法都入 ...
- 搭建本地SVN資料
基于網上眾多教程,搭建SVN成功:VisualSVN Server + TortoiseSVN Client. 過程比較簡單,就不重複書寫了. 部份參考資料,感謝作者: 什麽是SVN及如何應用 htt ...
- hystrix 应用问题
1.问题总结, 如果项目中使用了ThreadLocal,注意hystix创建新线程时,ThreadLocal中存的是之前线程中的数据,在hystix线程中获取不到 2.问题 throwable异常参数 ...
- 总结一下WindowListener的用法
记录一下便于自己查看 1.WindowListener java.awt.event 接口 WindowListener public interface WindowListener extends ...
- Angular 路由route实例
iSun Design & Code AngularJS - 路由 routing 基础示例 AngularJS 路由 routing 能够从页面的一个视图跳转到另外一个视图,对单页面应用来讲 ...
- 洛谷CF784E Twisted Circuit
(本题本来可能也就普及难度但是硬生生给评成了一道NOI难度的紫题,有点无语...) 这道题目是一道愚人节题目,本来只有下面的电路图,结果翻译完之后难度就直接没了. ------------ 言归正传, ...
- 【机器学习实战】第2章 K-近邻算法(k-NearestNeighbor,KNN)
第2章 k-近邻算法 KNN 概述 k-近邻(kNN, k-NearestNeighbor)算法主要是用来进行分类的. KNN 场景 电影可以按照题材分类,那么如何区分 动作片 和 爱情片 呢? 动作 ...
- python发送邮件 示例
示例1 import smtplib from email.mime.text import MIMEText from email.header import Header def sedmail( ...
- smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp10,DsCowAA3nir1u6xZq42WDw--.22935S2 1504492533,please
# from email.mime.text import MIMEText # # msg = MIMEText('hello, send by Python...', 'plain', 'utf- ...