题解 | #自守数#
自守数
http://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
let line;
function func(line) {
const num = parseInt(line);
let count = 0;
for(let i = 0; i <= num; i++) {
const sum = i * i;
const len = String(i).length;
// 获取尾部数字
const endNum = parseInt(String(sum).substr(String(sum).length - len,len));
if (endNum === i) count++;
}
return count;
}
while(line = readline()) {
print(func(line));
}