python 自守数,很好做
自守数
http://www.nowcoder.com/questionTerminal/88ddd31618f04514ae3a689e83f3ab8e
def is_num(n):
com = n * n - n
j = 0
a=1
sum =0
while j < len(str(n)):
a = a * 10
j = j + 1
if com % a == 0:
sum = 1
return sum
if name =='main':
while True:
try:
n = input()
sum = 0
a=1
for i in range(n): if is_num(i): sum = sum+1 print sum except: break