题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include<stdio.h> main() { int n; while (scanf("%d", &n) != EOF) { int i = 0, count = 0; for (i = 0; i <= n; i++) { int i2; int x = 1; i2 = i * i; //qiu比i大的10^x: int y = i; while (y)//注意y与i d的替换 { y /= 10; x *= 10; } if (((i2 - i) % x == 0)) { count++; } } printf("%d\n", count); } }