Ultraviolet A 113-power of cryptography

Source: Internet
Author: User

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
P. In this problem, given such IntegersNAndP,PWill always be of the form
For an integer
K(This integer is what your program must find ).

The input

The input consists of a sequence of integer PairsNAndPWith each integer on a line by itself. For all such pairs
,
And there exists an integer
K, Such that
.

The output

For each integer pairNAndPThe value shoshould be printed, I. e., the number
KSuch that.

Sample Input

21632774357186184021382204544

Sample output

431234

 

I feel that there will be Precision Problems in double ..

 

# Include <stdio. h>
# Include <math. h>
Void main ()
{Double N, P;
Long left, right, mid;
While (scanf ("% lf", & N, & P )! = EOF)
{Left = 0; Right = 1000000000;
While (left <right)
{Mid = (left + right)/2;
If (POW (MID, n) = P) break;
If (POW (MID, n)> P) Right = mid;
If (POW (MID, n) <p) Left = mid;
}
Printf ("% d \ n", mid );
}
}

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.