Using double to handle large integers & Taylor formula and error analysis
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 tions of these primes. Work in the has resulted in the practical use of results from number theory and other branches of mathematics once C Onsidered to be of the only theoretical interest.
This problem involves the efficient computation of an integer roots of numbers.
The Problem
Given An integer and an integer for your are to write a program that determines, the POSITIVE root of p. In this problem, given such integers n and p, the p would always be of the form for a int Eger k (This integer is what your program must find).
The Input
The input consists of a sequence of the integer pairs n and p with each integer in a line by itself. For all such pairs , and there exists a integer k, such that .
The Output
For each integer pair n and p the value should is printed, i.e., the number K such That .
Sample Input
2
3
7
4357186184021382204544
Sample Output
4
3
1234
Q: Give N and P, find out , but p can be very large ()
How do I store p? No big numbers.
Let's take a look at double. No: The index range is between -307~308 (10 base) and the valid number is 15 digits.
Error Analysis:
Order f (P) =p^ (1/n), Δ=f (P+δp)-F (P)
The Taylor formula was
(the upper bound of the ΔP is because the double has a maximum precision of 15 digits, and N has a lower bound because)
From the top-type, when the maximum Δp, n the smallest time the most error.