题解 | #自守数#

自守数

http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e

import java.io.*;
public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        while((str = br.readLine()) != null){
            int n = Integer.valueOf(str);
            int count = 0;
            for(int i = 0;i <= n; i++){
                int temp = i;
                int j = 1;
                while(temp != 0){
                    temp = temp/10;
                    j = j*10;
                }
                if((i*i-i)%j == 0){
                    count++;
                }
            }
            System.out.println(count);
        }
    }    
}
全部评论

相关推荐

06-12 16:23
已编辑
长安大学 C++
点赞 评论 收藏
分享
群星之怒:不是哥们,你就不好奇瘫痪三十年的老植物人是啥样的吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务