103271: [Atcoder]ABC327 B - A^A
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:13
Solved:0
Description
Score : $200$ points
Problem Statement
You are given an integer $B$.
If there exists a positive integer $A$ such that $A^A = B$, print its value; otherwise, output -1
.
Constraints
- $1 \leq B \leq 10^{18}$
- $B$ is an integer.
Input
The input is given from Standard Input in the following format:
$B$
Output
If there exists a positive integer $A$ such that $A^A = B$, print its value; otherwise, print -1
.
If there are multiple positive integers $A$ such that $A^A = B$, any of them will be accepted.
Sample Input 1
27
Sample Output 1
3
$3^3 = 27$, so print $3$.
Sample Input 2
100
Sample Output 2
-1
There is no $A$ such that $A^A = B$.
Sample Input 3
10000000000
Sample Output 3
10
Output
得分:200分
问题描述
给你一个整数$B$。
如果存在一个正整数$A$,使得$A^A = B$,则输出它的值;否则,输出-1
。
约束条件
- $1 \leq B \leq 10^{18}$
- $B$是一个整数。
输入
输入从标准输入按以下格式给出:
$B$
输出
如果存在一个正整数$A$,使得$A^A = B$,则输出它的值;否则,输出-1
。
如果存在多个正整数$A$,使得$A^A = B$,则任意一个都会被接受。
样例输入1
27
样例输出1
3
$3^3 = 27$,所以输出$3$。
样例输入2
100
样例输出2
-1
不存在$A$使得$A^A = B$。
样例输入3
10000000000
样例输出3
10
HINT
是否存在$A^A = B$,存在输出A,否则输出-1?