def solution(s: int)-> bool:
# your code here
return sum([pow(int(i),len(str(s))) for i in str(s)]) == s
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
def solution(s: int) -> bool:
sum = 0
for i in str(s):
sum += int(i) ** len(str(s))
return True if s == sum else False
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
Random random = new Random();
phone = random.nextInt(1000);
String S = String.valueOf(phone);
int sum=0;
List<Double> po=new ArrayList<Double>();
System.out.println("S:"+S);
for (int i = 0; i < S.length(); i++) {
double[] dou=new double[S.length()];
double d = Double.valueOf(S.substring(i, i + 1));
dou[i] = d;
int l = S.length();
double len = Double.valueOf(l);
double[] dm=new double[S.length()];
dm[i] = Math.pow(dou[i], len);
po.add(dm[i]);
}
for (int j=0; j<po.size();j++){
double in=po.get(j);
int in1=(int) in;
sum+=in1;
}
if (sum==phone){
System.out.println("他们是自恋数字:"+sum);
}else {
System.out.println("他们不是自恋数字:"+sum);
}
def test_solution(s: int) -> bool:
# your code here
return s == sum([int(i) ** len(str(s)) for i in str(s)])
if __name__ == '__main__':
assert test_solution(153) is True
assert test_solution(201) is False
assert test_solution(407) is True
def solution(s: int) -> bool:
return sum([int(i) ** len(str(s)) for i in str(s)]) == s
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
def solution(s: int) -> bool:
return sum([pow(int(i), len(str(s))) for i in str(s)]) == s
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
def solution(s: int)-> bool:
# your code here
return sum([int(i) ** len(str(s)) for i in str(s)]) == s
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
def solution(s: int)-> bool:
str_con = str(s)
sum = 0
le = len(str_con)
for i in str_con:
M = int(i) ** 3
sum += M
if sum == s:
return True
else:
return False
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True
def solution(s: int)-> bool:
return sum([int(str(s)[i])**len(str(s)) for i in range(len(str(s)))])==s
assert solution(153) is True
assert solution(201) is False
assert solution(407) is True