3 solutions

  • 0
    @ 2022-4-7 22:05:25
    #include<bits/stdc++.h>
    using namespace std;
    int week=6,sum;
    int main(){
    	for(register int year=2000;year<=2020;year++){
    		int	a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    		if((year%4==0&&year%100!=0)||year%400==0)a[2]=29;//闰年特判
    		for(register int month=1;month<=12;month++)
    			for(register int day=1;day<=a[month];day++){
    				if(day==1||week==1)sum+=2;//月初或者周一
    				else sum++;
    				week=(week+1)%7;//星期数增加
    				if(year==2020 && month==10 && day==1){
    					cout<<sum;
    					return 0;
    				}
    			}
    	}
    }

    Information

    ID
    6481
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    59
    Accepted
    25
    Uploaded By