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. CentOS6.X 系统安装后的基础优化

    特别说明:克隆之后的网卡修改 1 编辑eth0的配置文件:vi /etc/sysconfig/network-scripts/ifcfg-eth0, 删除HWADDR地址那一行及UUID的行如下: H ...

  2. 【总】java面试题

    100+经典Java面试题及答案解析 https://www.cnblogs.com/pureEve/p/6546280.html 2017 最新java面试题(技术面试) https://blog. ...

  3. 制作一个控制台小程序,要求:用户可以在控制到录入学生的姓名,当用户输入quit(不区分大小写)时,程序停止接收用户输入,并且显示出学生个数及姓名

    string name = string.Empty; //定义一个集合来接收学生 List<string> my = new List<string>(); do { Con ...

  4. 如鹏网学习笔记(五)MySql基础

    MySQL基础 一.数据库概念 1,网友装备信息.论坛帖子信息.QQ好友关系信息.学籍管理系统中的学生信息等都要“持久化”的保存到一个地方, 如果通过IO写到文件中,那么会非常麻烦,而且不利于多人共享 ...

  5. [javaSE] 基本数据类型对象包装类

    按照java面向对象的原则,每个基本类型都有对应的包装类 byte Byte short Short int Integer long Long boolean Boolean float Float ...

  6. [javaSE] 集合框架(Map概述)

    Map集合,将key对象映射到value对象 三个主要的子类:Hashtable,HashMap,TreeMap Hashtable:底层是哈希表数据结构,不允许使用null值,线程同步 HashMa ...

  7. MAC 系统 各种操作

    Part1:MAC如何打开活动监控器 1.第一种方法: 2.第二种方法 然后直接拖到dock中 Part2:Terminal 中的操作 一.如何开启apache 在终端输入sudo apachectl ...

  8. springboot----logback日志

    默认情况下,Spring Boot 配置 ERROR, WARN, INFO 三种日志级别.如果需要 Debug 级别的日志.在 src/main/resources/application.prop ...

  9. R 语言—基本绘图

    https://www.harding.edu/fmccown/r/   这个网站上有壮观的 R 绘制的实际图形 下面只记录自己感兴趣的内容 单变量绘图下包含 1. 带状图 2. 茎叶图 3. 直方图 ...

  10. 10、springboot之集成druid

    在pom.xml中添加 <dependency> <groupId>com.alibaba</groupId> <artifactId>druid< ...