Information
- ID
- 6481
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 62
- Accepted
- 26
- Uploaded By
#include<iostream>
using namespace std;
int days[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int is_leap(int y){ //判断闰年
return y % 400 == 0 || y % 4 == 0 && y % 100 != 0;
}
int daysOfMonth(int y, int m){
if( m == 2)
return is_leap(y) + 28;
return days[m];
}
int main(){
int y = 2000, m = 1, d = 1, w = 6; // 年,月,日,周几
int ans = 0;
while(y != 2020 || m != 10 || d != 2){
if(d == 1 || w == 1)
ans += 2;
else
ans++;
d++;
if(d > daysOfMonth(y, m))
d = 1, m++;
if(m > 12)
m = 1, y++;
w++;
if(w == 8)
w = 1;
}
cout << ans << endl;
return 0;
}
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.