题解 | #HJ099 自守数#

自守数

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

import java.util.Scanner;

/**
 * HJ99 自守数
 */
public class HJ099 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int count = 0;
            for (int i = 0; i <= n; i++) {
                int m = i * i;
                String s = Integer.toString(m);
                String t = Integer.toString(i);
                if (s.endsWith(t)) {
                    count++;
                }
            }
            System.out.println(count);
        }
        sc.close();
    }

}

全部评论

相关推荐

04-25 18:13
五邑大学 Java
后来123321:大二两段实习太厉害了,我现在大二连面试都没有
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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