题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
int n = scan.nextInt();
int[] count = new int[n+1];
int sum = 0;
for(int i = 0; i<=n; i++){
String s = Integer.toString(i);
if((i*i - i) % (Math.pow(10,s.length())) == 0){
count[i]++;
}
else{
continue;
}
}
for(int i : count){
if(i>0){
sum++;
}
// System.out.print(i);
}
System.out.print(sum);
}
scan.close();
}
}