题解 | 与7无关的数

#include <bits/stdc++.h>
using namespace std;

bool ob7(int x){
    while(x!=0){
        if(x%10==7)return true;
        x/=10;
    }
    return false;
}

bool is7(int x){
    if(x%7==0)return true;
    else if(ob7(x))return true;
    else return false;
}

int main(){
    int n;
    while(cin>>n){
        int ans=0;
        for(int i=1;i<=n;i++){
            if(!is7(i))ans+=i*i;
        }
        cout<<ans<<endl;
    }
}

数据量极小,直接枚举

全部评论

相关推荐

大飞的诡术妖姬:之前看b站多明海有个说法,日本就业竞争非常低的原因不光是毕业学生少,还有很多人干两年不喜欢职场氛围就辞职躺平,位置也空了很多,论吃苦耐劳还得看咱们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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