POJ 2109 Power of cryptography

Source: Internet
Author: User

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

Test instructions: kn = P, known as N,p, asks K. 1<=n<=, 1<=p<10101, 1<=k<=109

Analysis: I was also frightened, so big data, but see discuss said a word can AC, I think of K=pow (p,1.0/n); But K,p,n must be double .

As for why I checked:

Type length (bit) valid numeric absolute range
Float 32 6~7 10^ (-37) ~ 10^38
Double 64 15~16 10^ (-307) ~10^308
Long double 128 18~19 10^ (-4931) ~ 10 ^ 4932

Other people say this problem can be two points heightening accuracy, I will not do. Also have no language.

Power of cryptography

Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 19419 Accepted: 9804

Description

Cryptography involves (among other things) large prime numbers and computing powers of numbers among these Primes. resulted in the practical use of results from number theory and other branches of mathematics once C Onsidered to is only of theoretical interest.This problem involves the efficient computation of the integer roots of numbers. Given An integer n>=1 and an integer p>= 1 you had to write a program that determines the n th positive root of P. In this problem, given such integers n and p, p is always being of the form K to the nth. Power, for a integer k (this is the what your program must find).

Input

The input consists of a sequence of integer pairs N and p with each integer in a line by itself. For all such pairs 1<=n<=, 1<=p<10101and there exists an integer k, 1<=k<=109 such that kn = p.

Output

The For each integer pair n and p the value K should is printed, i.e., the number k such that K n =p.

Sample Input

2 163 277 4357186184021382204544

Sample Output

431234

POJ 2109 Power of cryptography

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.