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: ...
随机推荐
- 解读 iostat -mxd 1
#### for AWR 报告 : 建议如下: 不能随便调整db_file_multiblock_read_count 值, 取同样时间段的AWR 报告 02:00 ~ 05:00,所以db_file ...
- dtexec命令执行SSIS包
默认情况下,同时安装了 64 位和 32 位版本的 Integration Services 命令提示实用工具的 64 位计算机将在命令提示符处运行 32 位版本.运行 32 位版本的原因是:在 PA ...
- AJPFX关于Java中运用数组的四种排序方法
JAVA中在运用数组进行排序功能时,一般有四种方法:快速排序法.冒泡法.选择排序法.插入排序法.快速排序法主要是运用了Arrays中的一个方法Arrays.sort()实现.冒泡法是运用遍历数组进行比 ...
- DOCKER启动失败Job for docker.service failed because the control process exited with error code. See "syste mctl status docker.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl start docker Job for docker.service failed because the control process ...
- 洛谷 P1203 [USACO1.1]坏掉的项链Broken Necklace
坏掉的项链Broken Necklace 难度:★ Code: #include <iostream> #include <cstdio> #include <cstri ...
- Ubuntu 11.04 安装 cuda5.0
由于实验需要,于2016年10月15日再Ubuntu11.04安装cuda5.0,但是从网上查找Ubuntu11.04 只有对应的支持的cuda4 版本,cuda 5.0前面版本不支持IDE nisg ...
- 【虚拟机-网络IP】使用 Powershell 设置 VNET 中的静态 IP
本文包含以下内容 对已有虚机设置静态 Internal IP 取消对对已有虚机设置的静态 Internal IP 创建静态 Internal IP的虚机 使用中的注意点 请注意:以下操作需要下载最新版 ...
- [神经网络]一步一步使用Mobile-Net完成视觉识别(四)
1.环境配置 2.数据集获取 3.训练集获取 4.训练 5.调用测试训练结果 6.代码讲解 本文是第四篇,下载预训练模型并训练自己的数据集. 前面我们配置好了labelmap,下面我们开始下载训练好的 ...
- mangoDB笔记
1. 查询 db.表.find().pretty() find(querry,project) pretty()格式化显示 findOne() 返回一条结果 比较 db.Decl_In.find( ...
- Kubernetes之pod的属性
属性名称 取值类型 是否必选 取值说明 version String Required(必) 版本号,例如v1 kind String Required pod m ...