1095. Guess the Number

单点时限: 2.0 sec

内存限制: 256 MB

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=N^N 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.

样例

Input
4
3
4
3225
387420489
Output
-1
2
-1
9

24 人解决,41 人已尝试。

37 份提交通过,共有 136 份提交。

5.4 EMB 奖励。

创建: 17 年,1 月前.

修改: 6 年,8 月前.

最后提交: 9 月,2 周前.

来源: partychen

题目标签