1 条题解

  • 0
    @ 2024-8-25 9:46:03
    #include <bits/stdc++.h>
    using namespace std;
    
    bool isRun(int x){
        bool ans = false;
        if(x%100!=0&&x%4==0){
            ans = true;
        }
        else if(x%400==0){
            ans = true;
        }
        return ans;
    }
    
    int ans[8];
    int monthDay[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int weekDay = 0;
    int main(){
        memset(ans,0,sizeof(ans));
        int n;
        cin>>n;
        int curYear = 1900;
      
        while(!(curYear>=1900+n)){
            int curMonth = 1;
            //cout<<"dio";
            if(isRun(curYear)){
                monthDay[2] = 29;
            }
            else monthDay[2] = 28;
            for(int i = 1;i<=12;i++){
                for(int j = 1;j<=monthDay[i];j++){
              
                    weekDay++;
                    if(j==13){
                        ans[weekDay%7]++;
                    }
                }
            }
            curYear++;
        }
        cout<<ans[6]<<" "<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<" "<<ans[4]<<" "<<ans[5];
        return 0;
    }
    

    信息

    ID
    195
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    29
    已通过
    10
    上传者