题解 | 与7无关的数 (最短写法)

与7无关的数

https://www.nowcoder.com/practice/776d401bf86d446fa783f0bef7d3c096

#include <bits/stdc++.h>

using namespace std;

signed main() {
    int n;
    while (cin >> n) {
        long long res = 0;
        for (int i = 1; i <= n; i++) if (!(i % 7 == 0 || to_string(i).find('7') != string::npos)) res += i * i;
        cout << res << '\n';
    }   
    return 0;
}

全部评论

相关推荐

又被画饼了的山羊很英...:智能时钟是梅花的吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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