Codeforces Round #452 (Div. 2) BMonths and Years

Posted Visitor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #452 (Div. 2) BMonths 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;
}

以上是关于Codeforces Round #452 (Div. 2) BMonths and Years的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #452 (Div. 2) D

Codeforces Round #452 (Div. 2)

Codeforces Round #452 (Div. 2) BMonths and Years

Codeforces Round #452 (Div. 2) A Splitting in Teams

Codeforces Round #452 (Div. 2) DShovel Sale

Codeforces Round #452 (Div. 2) C Dividing the numbers