【Codeforces Round #452 (Div. 2) B】Months and Years
【链接】 我是链接,点我呀:)
【题意】
【题解】
闰,平,平 平,闰,平 平,平,闰 平,平,平 4种情况都考虑到就好。 可能有重复的情况。 但是没关系啦。【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 24;
int p[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int r[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
vector <int> v;
void cl(int a[],int b[],int c[]){
v.clear();
for (int i = 0;i < 12;i++) v.push_back(a[i]);
for (int i = 0;i < 12;i++) v.push_back(b[i]);
for (int i = 0;i < 12;i++) v.push_back(c[i]);
}
int n;
int a[N+10];
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++) cin >> a[i];
cl(r,p,p);
for (int i = 0;i < 36;i++)
{
int j = i+n-1;
if (j<36){
bool ok = true;
for (int k = i;k <= j;k++)
if (v[k]!=a[k-i+1]){
ok = false;
break;
}
if (ok){
cout <<"YES"<<endl;
return 0;
}
}
}
cl(p,r,p);
for (int i = 0;i < 36;i++)
{
int j = i+n-1;
if (j<36){
bool ok = true;
for (int k = i;k <= j;k++)
if (v[k]!=a[k-i+1]){
ok = false;
break;
}
if (ok){
cout <<"YES"<<endl;
return 0;
}
}
}
cl(p,p,r);
for (int i = 0;i < 36;i++)
{
int j = i+n-1;
if (j<36){
bool ok = true;
for (int k = i;k <= j;k++)
if (v[k]!=a[k-i+1]){
ok = false;
break;
}
if (ok){
cout <<"YES"<<endl;
return 0;
}
}
}
cl(p,p,p);
for (int i = 0;i < 36;i++)
{
int j = i+n-1;
if (j<36){
bool ok = true;
for (int k = i;k <= j;k++)
if (v[k]!=a[k-i+1]){
ok = false;
break;
}
if (ok){
cout <<"YES"<<endl;
return 0;
}
}
}
cout <<"NO"<<endl;
return 0;
}