CCF-报数(100分)

#include<iostream>
using namespace std;
int q[4];
bool has_seven(int x){
    if (x%7==0)return true;
    int t=x;
    while (t){
        if (t%10==7)return true;
        t/=10;
    }
    return false;
}
int main(){
    int n;
    cin>>n;
    int cnt=1;//当前枚举的数
    int res=1;//报了的数
    while(res<=n){
        if (has_seven(cnt)){
            q[cnt%4]++;
        }
        else res++;
        cnt++;
    }
    for(int i=1;i<4;i++)cout<<q[i]<<endl;
    cout<<q[0]<<endl;
    return 0;
}
posted @ 2020-08-04 20:37  进化の程序猿  阅读(407)  评论(0编辑  收藏  举报