다섯 자리 숫자인 16807은 75으로 5제곱수입니다. 또, 아홉 자리 숫자인 134217728은 89으로 9제곱수입니다.
n자리 숫자이면서 n제곱수도 되는 양의 정수는 모두 몇 개나 있습니까?
길이만 비교하면 되는거였는데..
문제를 잘못이해해서 .. 실제 값이 맞는지까지 비교하고 있었네...
숫자의 자리수는 log를 사용하면 구할 수 있다함.. 이 코드에서는 그냥 len 사용.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cnt=0 | |
for x in range(1, 10): | |
for n in range(1, 100): | |
if n == len(str(x**n)): | |
cnt+=1 | |
print (cnt) |