AcWing 1341. 十三号星期五
原题链接
简单
作者:
Value
,
2021-03-02 20:25:45
,
所有人可见
,
阅读 313
#include <iostream>
using namespace std;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int weekday[7];
int main(){
int n; cin >> n;
int days = 0;
for(int i = 1900; i < 1900 + n; i ++ ){
for(int j = 1; j <= 12; j ++ ){
weekday[(days + 12) % 7] ++ ;
days += month[j];
if(j == 2 && (i % 4 == 0 && i % 100 != 0 || i % 400 == 0)) days ++ ;
}
}
cout << weekday[5] << ' ' << weekday[6] << ' ';
for(int i = 0; i < 5; i ++ ) cout << weekday[i] << ' ';
return 0;
}