AcWing 1341. 十三号星期五
原题链接
简单
作者:
可持久化WA自动机
,
2021-01-20 09:01:01
,
所有人可见
,
阅读 350
算法1
#include<iostream>
using namespace std;
int n,m,k;
int cnt[7];
int day[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int get_day(int y,int m){
if((y % 4 == 0 && y % 100 != 0 || y % 400 == 0) && m == 2) return 29;
return day[m];
}
void solve(){
cin >> n;
int k = (2 + 13 - 1) % 7;
for(int y = 1900 ; y < 1900 + n ; ++y ){
for(int m = 1 ; m <= 12 ; ++m ){
cnt[k % 7]++;
k += get_day(y,m);
}
}
for(int i = 0 ; i < 7 ; ++i ) cout << cnt[i] << ' ';
cout << endl;
}
signed main(){
solve();
return 0;
}
/*
*
* ┏┓ ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃ ┃
* ┃ ━ ┃ ++ + + +
* ████━████+
* ◥██◤ ◥██◤ +
* ┃ ┻ ┃
* ┃ ┃ + +
* ┗━┓ ┏━┛
* ┃ ┃ + + + +Code is far away from
* ┃ ┃ + bug with the animal protecting
* ┃ ┗━━━┓ 神兽保佑,代码无bug
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛ + + + +
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛+ + + +
*/