题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include <iostream> #include <string> using namespace std; int main() { int a; while (cin >> a) { // 注意 while 处理多个 case auto count=0; for(auto i=0;i<=a;i++) { string str=to_string(i*i); if(to_string(i)==str.substr(str.size()-to_string(i).size(),str.size())) { count++; } } cout<<count; } } // 64 位输出请用 printf("%lld")