题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
n = int(input()) def func(i): stri = str(i**2) if stri.endswith(str(i)): # 是否以某个字符串结尾,参数需要是字符串 return True else: return False counter = 0 for i in range(n+1): if func(i): counter += 1 print(counter)