A-power of Cryptography uva113
Time limit:3000ms Memory limit:0kb 64bit IO format:%lld &%llu
Submit Status Practice UVA 113
Appoint Description:
Background
Cryptography involves (among other things) large prime numbers and computing powers of numbers modulo func tions of these primes. resulted in the practical use of results from number theory and other branches of mathematics once C Onsidered to is of only theoretical interest.
This problem involves the efficient computation of the integer roots of numbers.
The problem
Given an integer tex2html_wrap_inline32 and an integer tex2html_wrap_inline34 you is to write a program that determines t Ex2html_wrap_inline36, the positive tex2html_wrap_inline38 root of P. In this problem, given such integers n and p, p'll always be the of the form tex2html_wrap_inline48 for a integer k (this I Nteger is, your program must find).
The 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 tex2html_wrap_inline56, tex2html_wrap_inline58 and there exists an integer k, tex2html_wrap_inline62 s Uch that tex2html_wrap_inline64.
The Output
For each integer pair n and p the value tex2html_wrap_inline36 should is printed, i.e., the number k such that TEX2HTML_WR Ap_inline64.
Sample Input
2
16
3
27
7
4357186184021382204544
Sample Output
4
3
1234
Using the POW function to open P-square
#include <iostream>#include <algorithm>#include <map>#include <cstdio>#include <cstdlib>#include <vector>#include <cmath>#include <cstring>#include <string>using namespace STD;Const intmaxn=50005;typedef Long LongLL;intMain () {//freopen ("Text//in.txt", "R", stdin); DoublePintN while(~scanf("%D%LF", &n,&p)) {printf("%.0lf\n",POW(P,1./n)); }return 0;}
Welcome to the Csdn-markdown Editor