#P8813. [CSP-J 2022] 乘方
[CSP-J 2022] 乘方
Background
To simulate the scoring situation during a contest, the time limit of this problem is reduced by .
Problem Description
Xiaowen has just started learning competitive programming. One day, she ran into this problem: given positive integers and , find the value of .
Here, means multiplying by itself times. For example, means multiplying three 's together, and the result is .
“So easy!” Xiaowen thought, and she quickly wrote a program. However, it produced an error during testing.
Xiaowen soon realized that all variables in her program were of type int. On most machines, the largest number that int can represent is , so once the computed result exceeds this number, her program will fail.
Since Xiaowen has just learned programming, she worries that using int might cause problems. Therefore, she wants you to output -1 as a warning when the value of exceeds ; otherwise, output the correct value of .
However, Xiaowen still does not know how to implement this program, so she asks you for help.
Input Format
The input consists of one line with two positive integers .
Output Format
Output one line: if does not exceed , output ; otherwise output -1.
10 9
1000000000
23333 66666
-1
Hint
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that , and .
For of the testdata, it is guaranteed that .
: One additional set of testdata has been added each time.
Translated by ChatGPT 5