题解 | #自守数#

自守数

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")

全部评论

相关推荐

真三hjdlxn:这么能吹还能找不到实习啊? 市分行写TOP投行,2个月的实习写半页。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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