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 pp will always be of the form  for an integerk (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

double能表示的范围是-1.7e308 ~ 1.7e308,精度至少为15位,而输出结果在int的范围内,即10位,所以可以输出可以用double

至于计算过程中为什么能用double而不会影响到结果,我也暂时没搞懂,因为double的精度只有15位,最多也才有16位,但是p的范围是10^101,输入过程中用的也不是科学计数法,15位后的值肯定被抹掉了,结果却是对的。

正确的分析应该在这:http://blog.csdn.net/synapse7/article/details/11672691,用到了误差分析,得出的结果是在这一题里失去的精度不会影响答案,等我数学补上来之后来研究(吐槽一下网上的好多人,风轻云淡的就发上来了,真的懂了么?自己不扎实不要紧,关键在于误导了新手)

 #include<stdio.h>
#include<math.h> int main(void)
{
double n,p; while(scanf("%lf%lf",&n,&p) != EOF)
printf("%.lf\n",pow(p, / n)); return ;
}

UVA 113 Power of Cryptography (数学)的更多相关文章

  1. POJ-2109 Power of Cryptography(数学或二分+高精度)

    题目链接: https://vjudge.net/problem/POJ-2109 题目大意: 有指数函数 k^n = p , 其中k.n.p均为整数且 1<=k<=10^9 , 1< ...

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

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

  3. [POJ2109]Power of Cryptography

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

  4. 贪心 POJ 2109 Power of Cryptography

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

  5. poj 2109 Power of Cryptography

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

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

  7. POJ2109——Power of Cryptography

    Power of Cryptography DescriptionCurrent work in cryptography involves (among other things) large pr ...

  8. uva 10330 - Power Transmission(网络流)

    uva 10330 - Power Transmission 题目大意:最大流问题. 解题思路:増广路算法. #include <stdio.h> #include <string. ...

  9. UVA 11149 - Power of Matrix(矩阵乘法)

    UVA 11149 - Power of Matrix 题目链接 题意:给定一个n*n的矩阵A和k,求∑kiAi 思路:利用倍增去搞.∑kiAi=(1+Ak/2)∑k/2iAi,不断二分就可以 代码: ...

随机推荐

  1. spring中propertyplaceholderconfigurer简介

    Spring的框架中为您提供了一个 BeanFactoryPostProcessor 的实作类别: org.springframework.beans.factory.config.PropertyP ...

  2. PostgreSQL停止动作观察

    实验过程如下: 启动一个客户端: [postgres@cnrd56 bin]$ ./psql psql () Type "help" for help. postgres=# be ...

  3. Softmax 回归原理介绍

    考虑一个多分类问题,即预测变量y可以取k个离散值中的任何一个.比如一个邮件分类系统将邮件分为私人邮件,工作邮件和垃圾邮件.由于y仍然是一个离散值,只是相对于二分类的逻辑回归多了一些类别.下面将根据多项 ...

  4. 标准SAP中的物料类型

    DIEN -服务 ERSA -备件 FERT -成品 HALB -半成品 HAWA -贸易商品 HIBE -经营供应 LEER -虚拟件 NLAG -费存储物料 ROH -原材料 VERP -包装 W ...

  5. discuz+ecmall+phpcms整合

    所需软件 discuzx1.5 (包含ucenter1.5) ecmall2.3 phpcms v9.5 1.先安装discuz1.5 2.然后安装ecmall2.3 3.最后安装phpcms v9. ...

  6. NGINX源代码剖析 之 CPU绑定(CPU亲和性)

    作者:邹祁峰 邮箱:Qifeng.zou.job@gmail.com 博客:http://blog.csdn.net/qifengzou 日期:2014.06.12 18:44 转载请注明来自&quo ...

  7. 用ASP实现简单的繁简转换

    用ASP实现简单的繁简转换 国际化似乎是一个很流行的口号了,一个站点没有英文版至少也要弄个繁体版,毕竟都是汉字,翻译起来不会那么麻烦:P 一般的繁简转换是使用字典,通过GB的内码算出BIG5字符在字典 ...

  8. 安装jasperwave出错

    1.错误描写叙述 2.错误原因 无法下载"com.jasperwave.engine_1.1.0.jar",须要又一次下载 3.解决的方法 将"com.jasperwav ...

  9. How does a relational database work

    http://blog.jobbole.com/100349/ http://coding-geek.com/how-databases-work/

  10. Ubuntu下VSFTPD(五)(匿名FTP设置方法)

    匿名FTP设置方法: 通常在登录FTP服务器的用户不确定的情况下,应将FTP服务器设置为允许匿名账号登录的FTP服务器 1.启用匿名帐号   anonymous_enable=YES   local_ ...