UVa 113 / POJ 2109 Power of Cryptography

使用double处理大整数&泰勒公式与误差分析

113 - Power of Cryptography

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=49

http://poj.org/problem?id=2109

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

题意:给出n和p,求出 ,但是p可以很大()

如何存储p?不用大数可不可以?

先看看double行不行:指数范围在-307~308之间(以10为基数),有效数字为15位。

误差分析:

令f(p)=p^(1/n),Δ=f(p+Δp)-f(p)

则由泰勒公式得

(Δp的上界是因为double的精度最多是15位,n有下界是因为

由上式知,当Δp最大,n最小的时候误差最大。

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索误差
, integer
, and
, Mathematics
, of
, The
, problem
such
poj2109、cryptography、cryptography 安装、cryptography安装失败、python cryptography,以便于您获取更多的相关知识。

时间: 2024-10-06 05:41:30

UVa 113 / POJ 2109 Power of Cryptography的相关文章

poj 2109 Power of Cryptography

今天懒了,这道题直接去看了大家的帖子,三行搞定... 题目大意: K ^ N = P, 给N 和 P, 求K.数据规模 :1<=n<= 200, 1<=p<10101 and there exists an integer k, 1<=k<=109 . 看到1<=p<10101 我就去想大数操作了,后来发现原来double完全可以放. 类型          长度 (bit)           有效数字          绝对值范围float       

UVa 270 / POJ 1118 Lining Up:计算几何

270 - Lining Up Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=206 http://poj.org/problem?id=1118 ``How am I ever going to solve this problem?" sai

UVa 10038 / POJ 2575 / ZOJ 1879 Jolly Jumpers (water ver.)

10038 - Jolly Jumpers Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=979 http://poj.org/problem?id=2575 http://acm.zju.edu.cn/onlinejudge/showProblem.do?

UVa 748/POJ 1001 Exponentiation:浮点高精度求幂&amp;amp;正则表达式的应用

748 - Exponentiation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=689 http://poj.org/problem?id=1001 Problems involving the computation of exact values

UVa 755 / POJ 1002 487--3279 (排序)

755 - 487--3279 Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=696 http://poj.org/problem?id=1002 Businesses like to have memorable telephone numbers. On

UVa 706 / POJ 1102 LCD Display (模拟)

706 - LCD Display Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=647 http://poj.org/problem?id=1102 A friend of you has just bought a new computer. Until

算法:poj 4045 Power Station (树形dp)

题意 n个城市节点构成的一棵树,节点i到节点j的电量损耗为 I*I*R*(i到j的路径所含边数),现 在要在某个结点上修建一个供电站,使得这个结点到所有其它节点的总损耗量最小. 思路 典型的树形dp 可以先用一次dfs求出每一点的子树结点个数num[u],以及每一点到它子树所有结点的总 距离f[u][0]; 然后再用一次dfs,推出每个结点到除去它子树部分的结点总距离f[u][1]. f[v][1] = (f[u][0]-f[v][0]-num[v]) + f[u][1] + n - num[v

UVa 10706 / POJ 1019 Number Sequence:打表及O(1)算法

10706 - Number Sequence Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=19&page=show_problem&problem=1647 http://poj.org/problem?id=1019 Description A single positive integer i is giv

UVa 1193 / POJ 1328 Radar Installation:贪心及区间选点

1193 - Radar Installation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3634 http://poj.org/problem?id=1328 Assume the coasting is an infinite straight line. Land is in one side of coas