题解 | #挑7#

挑7

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

#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a;
    while (cin >> a) { // 注意 while 处理多个 case
        vector<int>vec;
        set<int>s;
        for(auto i=1;i<=a;i++)
        {
            if(i%7==0)
            {
                vec.push_back(i);
            }
            string str=to_string(i);
            if(find(str.begin(),str.end(),'7')!=str.end())
            {
                vec.push_back(stoi(str));
            }
        }
        for(auto v : vec)
        {
            s.insert(v);
        }
        cout<<s.size();
        
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

哞客37422655...:github如果提交不是很多 可以不写 可能会是减分项。之前听别人讲过的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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