题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
int res = 0;
cin >> n;
for(int i=0; i<=n; i++){
int a = pow(i,2), b = i;
int num = 1;
while(b/10 != 0){
num += 1;
b /= 10;
}
int s = pow(10,num);
a %= s;
if(a == i){
res ++;
}
}
cout << res << endl;
return 0;
}
// 64 位输出请用 printf("%lld")
这个题的特点在于如何截取大数的低几位数据。
