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 ...
随机推荐
- CF898A Rounding
题意翻译 给你一个数字,将其“四舍六入”,末尾为5舍去或进位都可,求最终的数字. 题目描述 Vasya has a non-negative integer n n n . He wants to r ...
- django中的验证码
from django.shortcuts import renderfrom PIL import Imagefrom PIL import ImageDrawfrom PIL import Ima ...
- [PHP] 从 PHP 5.3.X 迁移到 PHP 5.6.X不兼容点
从 PHP 5.3.X 迁移到 PHP 5.4.X不兼容点: 1.不再支持 安全模式 2.移除 魔术引号,设置 magic_quotes_gpc 系列将不会生效 3.Salsa10 和 Salsa20 ...
- JMX 远程监控 Linux tomcat 功能实现
作者远程服务器操作系统 CentOS 7.0, tomcat 版本 7.0 1. Linux tomcat 配置 1.1 catalina_opt 配置 可以在 catalina.sh 文件中添加如下 ...
- SpringMVC_关于<url-pattern>
一.配置 在没有特殊要求的情况下,SpringMVC的中央调度器DispatcherServlet的<url-oattern/>常使用后缀匹配的方式,如写*do. 二.不能写为/* 这 ...
- php格式化保留2位小数
<td align="center"><?php echo sprintf("%.2f",$v[r][red_bag_money]);?> ...
- Thymeleaf学习记录(8)--表达式基本对象
基础对象 #ctx:上下文对象 /* * ====================================================================== * See ja ...
- [翻译]Review——Learn these core JavaScript concepts in just a few minutes
Learn these core JavaScript concepts in just a few minutes(只需几分钟即可学习这些核心JavaScript概念) 原文地址:https://m ...
- 02:奇数单增序列 个人博客doubleq.win
个人博客doubleq.win 02:奇数单增序列 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 给定一个长度为N(不大于500)的正整数序列,请将其中的所 ...
- 【javascript】javasrcipt设计模式之状态模式
使用场景 解决多个[ifelse]嵌套,将其封装成若干个方法 区分事物内部的状态,事物内部的状态的改变往往会带来事物的行为的改变 简单的多个状态直接切换的时候 //两个状态之间的切换,使用if-els ...