题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
只需要考虑n的平方是否以n结尾即可,注意需要转换成字符串才能进行操作,代码如下:
while True: try: n = int(input()) m = 0 for i in range(n+1): if str(i ** 2).endswith(str(i)): m += 1 print(m) except: break