题解 | #自守数#

自守数

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

const readline = require("readline");

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on("line", function (line: string) {
    const num = parseInt(line);
    let count = 0;
    for (let i = 0; i <= num; i++) {
        const sqrtStr = String(i * i);
        const tail = sqrtStr.substring(sqrtStr.length - String(i).length);
        if (tail === String(i)) {
            count++;
        }
    }
    console.log(count);
});

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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