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