题解 | 挑7 最简单写法

挑7

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

#include <iostream>
#include <string>
using namespace std;

int main() {
    int n,ans=0;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        string s=to_string(i);
        if(s.find('7') != string::npos || i%7==0)
            ans++;
    }

    cout<<ans;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

09-19 14:17
门头沟学院 Java
点赞 评论 收藏
分享
09-17 17:09
门头沟学院 Java
雨忄:有人给出过解法,拖晚点去,然后到时候再找其他理由商量,既增加他们的筛人成本,不一定会给你收回offer ,也能占位避免工贼
秋招的嫡长offer
点赞 评论 收藏
分享
牛客40297450...:不是研究生强,是你强
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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