SOJ 1017 Power of Cryptography 库函数精度
Background
Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of 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 of only theoretical interest.
This problem involves the efficient computation of integer roots of numbers.
The Problem
Given an integer
and an integer
you are to write a program that determines
, the positive
root of p. In this problem, given such integers n and p, p will always be of the form
for an integer k (this integer is what your program must find).
The 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
,
and there exists an integer k,
such that
.
The Output
For each integer pair n and p the value
should be printed, i.e., the number k such that
.
Sample Input
2
16
3
27
7
4357186184021382204544
Sample Output
4
3
1234 解题思路:
本题直接用pow求解就好,不过可能存在四舍五入一类的精度问题需要处理,所以要特别小心
AC代码:
#include<stdio.h>
#include<math.h>
int main()
{
double p,k;
double n;
while(scanf("%lf%lf",&n,&p)==)
{
k= pow (p,1.0/n);
long long ans=k;
if(pow(ans,n)!=p)printf("%ld\n",ans+);
else printf("%ld\n",ans);
}
return ;
}
SOJ 1017 Power of Cryptography 库函数精度的更多相关文章
- 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 数学题 double和float精度和范围
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...
- Power of Cryptography(用double的泰勒公式可行分析)
Power of Cryptography Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...
- UVA 113 Power of Cryptography (数学)
Power of Cryptography Background Current work in cryptography involves (among other things) large p ...
- 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: 26622 Accepted: ...
- [POJ2109]Power of Cryptography
[POJ2109]Power of Cryptography 试题描述 Current work in cryptography involves (among other things) large ...
- 贪心 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 ...
随机推荐
- 十一:image 图片
属性名 类型 默认值 说明 src String 图片资源地址 mode String 'scaleToFill' 图片裁剪.缩放的模式 binderror HandleEvent 当错误发生 ...
- 微信授权错误:"errcode":40163,"errmsg":"codebeenused
微信网页授权获取code值回调两次的问题 1.说是域名原因,目前未测试,没有正确的域名 问题描述:在调用微信网页授权获取openid值时,先获取的code值,但是code值的接口 会走两次回调.而co ...
- Class类文件结构简介
Java跨平台的基础 各种不同平台的虚拟机与所有平台都统一使用的程序存储格式——字节码(ByteCode)是构成平台无关性的基石,也是语言无关性的基础.Java虚拟机不和包括Java在内的任何语言绑定 ...
- 分布式微服务技术之 Spring Cloud Netflix
1 背景 Netflix 是全球十大视频网站中唯一收费站点,是美国互联网流媒体播放商,由于访问量巨大,转型为云计算公司. 由Netflix公司主持开发了一套代码框架和库Netflix OSS即open ...
- uva 725 DIVISION (暴力枚举)
我的56MS #include <cstdio> #include <iostream> #include <string> #include <cstrin ...
- jquery怎么取得有好几个并且name是相同的值
jQuery("input[name='number']").each(function(){ alert(jQuery(this).val()); });
- jQuery和MVVM类框架的编程区别点
本文说的mvvm框架以react为列,其他应该也是类似的: react实际上仅仅是帮助我们再View层简化,让我们仅仅需要专注数据,只要数据改变,所有的视图就会自己跟随着改变, 本人自己做react项 ...
- JSON运用——PHP中使用json数据格式定义字面量对象的方法
目前,在PHP中是不支持字面量命名法. 前端的小伙伴都知道,在JS中用字面量定义一个对象的方法可以如下: var o = { 'name' : 'Tom' , 'url' : 'www.baidu.c ...
- python 网络 socket
---恢复内容开始--- 1.socket Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口.在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏 ...
- centos7 安装 maven 和ant git 以及 rocketmq 4.2安装过程(安装成功,调用失败)
1.maven 安装 wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /et ...