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 pp 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 库函数精度的更多相关文章

  1. poj 2109 Power of Cryptography (double 精度)

    题目:http://poj.org/problem?id=2109 题意:求一个整数k,使得k满足kn=p. 思路:exp()用来计算以e为底的x次方值,即ex值,然后将结果返回.log是自然对数,就 ...

  2. POJ 2109 Power of Cryptography 数学题 double和float精度和范围

    Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...

  3. Power of Cryptography(用double的泰勒公式可行分析)

    Power of Cryptography Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

  4. UVA 113 Power of Cryptography (数学)

    Power of Cryptography  Background Current work in cryptography involves (among other things) large p ...

  5. 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 ...

  6. POJ 2109 -- Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26622   Accepted: ...

  7. [POJ2109]Power of Cryptography

    [POJ2109]Power of Cryptography 试题描述 Current work in cryptography involves (among other things) large ...

  8. 贪心 POJ 2109 Power of Cryptography

    题目地址:http://poj.org/problem?id=2109 /* 题意:k ^ n = p,求k 1. double + pow:因为double装得下p,k = pow (p, 1 / ...

  9. poj 2109 Power of Cryptography

    点击打开链接 Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16388   Ac ...

随机推荐

  1. 20个专业H5(HTML5)动画工具推荐

    AnimateMate 可能是最好的 Sketch 动画插件.Sketch 目前被广泛应用于 HTML5 的原型界面设计,或者被应用于数据可视化的,动画部分则一般经由软件 Principle 等实现. ...

  2. [转]Creating an OData v3 Endpoint with Web API 2

    本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata- ...

  3. facebook 登录开发记录

    1.注册一个 facebook 的账号 2.进入 facebook 开发者的网站.(也可以在 facebook 登录后,点击自己的名字进入用户信息页面,在该页面的底部有个“更多”的链接,点击进去会看到 ...

  4. RabbitMQ---4、消息确认Ack

    一:消费者确认 消费者确认或者说消费者应答指的是RabbitMQ需要确认消息到底有没有被收到 - 自动应答 boolean autoAck = true; channel.basicConsume(Q ...

  5. golang命令和VSCode配置

    Go是一门全新的静态类型开发语言,具有自动垃圾回收.丰富的内置类型.函数多返回值.错误处理.匿名函数.并发编程.反射等特性 golang常用命令: go env #查看go的环境 echo %GORO ...

  6. android recycleView 简单使用二---分割线

    转自:https://www.jianshu.com/p/b46a4ff7c10a RecyclerView没有像之前ListView提供divider属性,而是提供了方法 recyclerView. ...

  7. ASP.NET 表单验证方法与客户端(浏览器)服务器交互机制的故事

    想到这个问题完全是一个意外吧,是在寻找另外一个问题答案的过程中,才对验证方法与浏览器服务器交互机制的关系有了清晰的认识. 先说下验证方法,验证方法分为前台验证和后台验证. 前台验证就是类似jQuery ...

  8. 线程不安全的类不要轻易做为static变量使用,及如何使用ThreadLocal将共享变量变为独享变量

    参考原文:<关于SimpleDateFormat安全的时间格式化线程安全问题>

  9. PowerDesigner16导出SQL时如何添加注释

    添加注释方法 https://jingyan.baidu.com/article/47a29f24652e44c0142399c3.html 重点是修改value的值 alter table [%QU ...

  10. css实现修改默认滚动条样式

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head&g ...