PE其他解題報告請參考這裏,本題答案在留言首條
Powerful digit counts
Problem 63
The 5-digit number, , is also a fifth power. Similarly, the 9-digit number, , is a ninth power.
How many n-digit positive integers exist which are also an nth power?
題意:
問你存在多少n位數字,是某數的n次冪這種組合
分析:
暴力題,python大發好啊
參考代碼
cnt = 0
for i in range(1,1000):
for j in range(1, 1000):
l = len(str(pow(j, i)))
if (l > i) :break
if (l == i):
cnt += 1
print(cnt)
閱讀好習慣:點贊 + 收藏~