题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> int main() { int n; scanf("%d", &n); int count = 0, count2 = 1; for (int i = 1; i <= n; i++) { int num = i; while (num) { num /= 10; count++; } int mod = (int)(i * i) % ((int)pow(10, count)); if (mod == i) { count2++; } count = 0; } printf("%d", count2); return 0; }