UVa 113/POJ 2109 Power of cryptography

Source: Internet
Author: User
Tags time limit

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.