【十二题解】 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include<stdio.h>
int judge(int n){
int ans = 0;
for(int i=0; i<=n; i++){
int all = i*i;
int x = i;
int sign = 1;
while(x!=0){
if(x%10 != all%10){
sign = 0;
break;
}
x/=10;
all/=10;
}
if(sign)ans++;
}
return ans;
}
int main(){
int number;
while(scanf("%d", &number) != EOF){
int ans=judge(number);
printf("%d\n", ans);
}
}