日期模拟
蓝桥杯这次还是躲不过日期问题吗
https://ac.nowcoder.com/acm/contest/12797/C
#include<bits/stdc++.h>
using namespace std;
int cnt;
int yue[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int rn(int x) {
return (x%4==0&&x%100) || (x%400==0);
}
int main(){
int n,y,r,w;
n=1937,y=1,r=1,w=5;
while(1){
r=r%yue[y]+1;
if(r==1) y=y%12+1;
if(y==1&&r==1) n++;
if(y==2){
if(rn(n)) yue[y]=29;
else yue[y]=28;
}
w=w%7+1;
if(w%7==1) cnt++;
if(n==2021&&y==3&&r==20) break;
}
cout << cnt;
return 0;
}
蓝桥真题 文章被收录于专栏
蓝桥真题的题解
