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. yii2 页面加载警告框

    在视图页面代码如下 <?php use kartik\alert\Alert; echo Alert::widget([ 'type' => Alert::TYPE_INFO, 'titl ...

  2. jQuery 判断元素上是否绑定了事件

    我研究了一下之后发现,jQuery都将事件缓存起来了,其实也是为了防止内存溢出以及页面unload的时候的速度,也包括多函数触发,方便管理等诸多好处,具体可以参考此文. jQuery会在window. ...

  3. 如鹏网学习笔记(十四)ASP.NET

    Asp.net笔记 一.Socket类 进行网络编程的类,可以在两台计算机之间进行网络通讯 过程: 向服务器发送指令: GET /index.html HTTP/1.1 Host:127.0.0.1: ...

  4. 手把手教你用 Keras 实现 LSTM 预测英语单词发音

    1. 动机 我近期在研究一个 NLP 项目,根据项目的要求,需要能够通过设计算法和模型处理单词的音节 (Syllables),并对那些没有在词典中出现的单词找到其在词典中对应的押韵词(注:这类单词类似 ...

  5. JAVA注释方式

    1.单行(single-line)注释    //…… 2.块(block)注释                /*……*/ 3.文档注释                      /**……*/

  6. 记Spring与跨域

    跨域 简单理解就是跨域名 (ip+端口) 在 52liming.com 中向demo.com中发起Ajax请求, 出于安全考虑会进行拦截 参考: 浏览器的同源策略 什么是JS跨域访问? 跨域资源共享 ...

  7. 【SSH网上商城项目实战24】Struts2中如何处理多个Model请求

       转自: https://blog.csdn.net/eson_15/article/details/51465067 1. 问题的提出 Struts2中如果实现了ModelDriven<m ...

  8. 5.Resource注解解析

    Resource有两种使用场景 1.Resource 当Resource后面没带参数的时候是根据它所注释的属性名称到applicationContext.xml文件中查找是否有bean的id与之匹配, ...

  9. 判断有几个checkbox被选中

    //判断是否有选中的checkbox的值是否为空 var number = $("input[type='checkbox']:checked").length; if(numbe ...

  10. python学习之老男孩python全栈第九期_day023知识点总结——类和对象命名空间、组合

    一. 类和对象命名空间类里 可以定义两种属性: 1. 静态属性 2. 动态属性 class Course: language = 'Chinese' def __init__(self, teache ...