codeforces 899b
题目大意:给出不超过24个数字,判断是否是连续的月份
思路:打表循环判断
要注意平平年 平闰年 闰闰年
ac代码:
#include<bits/stdc++.h>
using namespace std;
int m[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int m1[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
int mon[24];
int main() {
int n;
while(~scanf("%d",&n)) {
m1[1] = 29;
for(int i = 0; i < n; i++) {
scanf("%d",&mon[i]);
}
int flag = 0;
for(int i = 0; i < 12; i++) {
if(mon[0] == m[i] || mon[0] == m1[i]) {
if(mon[0] == 29) {
m1[1] = 28;
}
int j = i;
int count = 1;
int sum = 0;
while(1) {
sum++;
j++;
j %= 12;
if(count == n) {
flag = 1;
break;
}
if(mon[sum] == m[j] || mon[sum] == m1[j]) {
if(mon[sum] == 29) {
m1[1] = 28;
}
}
else {
break;
}
count++;
}
}
}
if(flag) {
printf("Yes\n");
}
else{
printf("No\n");
}
}
return 0;
}