## WC '97 P2 - Power of Cryptography

View as PDF

Points: 20
Time limit: 1.0s
Memory limit: 16M

Problem type
Allowed languages
Assembly, Brain****, C, C++, COBOL, Forth, Fortran, Java, Lua, Prolog, Text, Turing
##### 1997 Woburn Computer Programming Challenge

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 and an integer you are to write a program that determines the -th root of — it is guaranteed that is the -th power of some integer , i.e. for some integer ; this is the integer you are to find.

#### Input Specification

The first line of the input is , the number of test cases to consider.
The input consists of pairs of numbers and with each number on a line by itself. For all of these pairs, and there exists an integer , such that .

#### Output Specification

For each set of values for and output the value of .

#### Sample Input

3
2
16
3
27
7
4357186184021382204544

#### Sample Output

4
3
1234