题解 | #挑7#

挑7

https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b

#include <iostream>
using namespace std;

bool find7(int n){
    if(n%7==0)return true;
    while(n){
        if(n%10==7)return true;
        n = n/10;
    }
    return false;
}
int ans(int n){
    int res=0;
    for(int i=7; i<=n;i++){
        if(find7(i))res++;
    }
    return res;
}
int main() {
    int n;
    cin>>n;
    cout<<ans(n);
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
09-25 11:39
已编辑
北京航空航天大学 Java
我的代码出BUG了:@美团@腾讯@字节跳动@阿里巴巴。你们好好看看吧,你们就挂我吧,到时候被人家鸽穿还得录取我
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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