题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int cnt = 0;
for (int i = 0; i <= n; ++i){
if (i % 10 == 0 || i % 10 == 1 || i % 10 == 5 || i % 10 == 6){
string str1 = to_string(i);
string str2 = to_string(i * i);
int pos = str2.size() - str1.size();
if (str2.find(str1, pos) != string::npos){
++cnt;
}
}
}
cout << cnt << endl;
}
return 0;
}
#你觉得今年春招回暖了吗##23届找工作求助阵地##我的实习求职记录##零基础学习C++##14天打卡计划#

查看10道真题和解析