【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;
}
【Codeforces Round #452 (Div. 2) B】Months and Years的更多相关文章
- 【Codeforces Round #452 (Div. 2) A】 Splitting in Teams
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 贪心 1优先和2组队. 如果1没有了 就结束. 如果1还有多余的. 那么就自己3个3个组队 [代码] #include <bi ...
- 【Codeforces Round #452 (Div. 2) C】 Dividing the numbers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两 ...
- 【Codeforces Round #452 (Div. 2) D】Shovel Sale
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 让N乘2->a 然后看一下位数是多少. 假设有x位(x>=2) 则(0..(a%10-1) ) + (99..9)[x- ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- double long float类型读入读出 double取模 fmod
The library of fmod is #include <cmath> #include<cstdio> #include<cstdlib> #includ ...
- lightoj--1008--Fibsieve`s Fantabulous Birthday(水题)
Fibsieve`s Fantabulous Birthday Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld &a ...
- POJ 3193 字符串排序+比较
思路: 1. 先把那m个排个序 此后每回二分+strncmp一下就好了 strncmp是个好东西啊-- 2. hash判判 (注意 hash会有冲突--------.) //By SiriusRen ...
- 紫书 习题 10-44 UVa 11246 ( 容斥原理)
把k的倍数的删去(k, 2k, 3k--),但是k^2不应该删去,因为k已经删去,所以不存在某个数乘上k之后为k^2 所以k^2可以留下,然后因为有k^2,所以k^3就是k^2的k倍,所以k^3要删去 ...
- 解决WIN7远程登录提示无法保存凭据的问题
事由:今天到公司,想起手上还有点小东西没有改动完,就打算连上server进行小改动.结果发现昨天还能好好的远程连接server的WIN7,今天突然间不能远程登录了~ 无奈~悲催~ 我仅仅能猜是不是有什 ...
- 在OEL 5.4 32bit上使用yum install命令遇到的问题
在OEL 5.4 32bit上使用yum install命令遇到的问题 [root@localhost yum.repos.d]# yum install elfutils-libelf-devel- ...
- js02---字符串
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- vim基础学习之自动补全功能
本章我们学习自动补全功能1.自动补全优先从当前的编辑区获得补全列表例如:我们写下如下内容 aaaaa aabbb aaab 当我们再次输入aa,然后我们按下Tab的时候,会弹出一个包含 aaaaa a ...
- css3.0滚动条的优化
.ass_showFriends{width: 93%;height: 8.35rem;overflow-y: auto;} .ass_showFriends::-webkit-scrollbar{w ...
- col---过滤控制字符