1997 Woburn Computer Programming Challenge
2. Power of Cryptography
Current work in cryptography involves (among other things) computing large prime numbers and computing powers of numbers modulo these large primes. Work in this area has resulted in the practical use of result from number theory and other branches of mathematics once considered to be only of theoretical interest. This problem involves the efficient calculation of integer roots of numbers.
Given an integer n ≥ 1 and an integer p ≥ 1 you are to write a program that determines the nth root of p — it is guaranteed that p is the nth power of some integer k, i.e. p=kn for some integer k; this is the integer you are to find.
InputThe first line of the input is M, the number of test cases to consider.
The input consists of M pairs of numbers n and p with each number on a line by itself. For all of these pairs, 1 ≤ n ≤ 200, 1 ≤ p ≤ 10101 and there exists an integer k, 1 ≤ k ≤ 10101 such that
OutputFor each set of values for n and p output the value of k.
3 2 16 3 27 7 4357186184021382204544
4 3 1234
Point Value: 20
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 28, 2008
C++03, PAS, C, ASM, C#, C++11