1701Guess the Number

1701   Guess the Number

题目描述

In this problems, we'll talk about BIG numbers. Yes, I'm sorry, big numbers again.... Let N be a positive integer, we call S=NN the "big big power" of N. In this time, I will calculate the exact value of S for a positive integer N. Then, I tell you S, you guess N.

Note that I may make mistakes in calculating, but I promise that if I'm wrong, my result and the correct result will differ in exactly one single digit, and the number of digits is always correct(no missing or extra digits). That means, I will NOT get 'terribly wrong result' such as 3456 or 111.

输入格式:

The first line in the input contains a positive integer T indicating the number of test cases (1<=T<=10). Each case consists of a single line containing the exact value of S. The line does not contain any character apart from digits (0,1,2...9), and will have at most 500,000 digits. Input integers do NOT contain leading zeros.

输出格式:

For each test case, print on a single line the value of N if a unique N satisfying N^N=S can be found. Otherwise, print -1 in the corresponding line, showing that I made a mistake in calculating.

输入样例 复制
4
3
4
3225
387420489

输出样例 复制
-1
2
-1
9


说明

3
13
通过提交
时空限制2000ms/64mb
题目来源
评测方式在线评测
题目类型
难        度