题目大意:问你是否存在一个非闰年,使得某个月的开始为第一行所给的星期,下一个月开始为第二行所给的星期
直接模拟即可。
或者因为每个月天数固定,所以只需要考虑特定的几种情况
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[29]={0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
string x1,x2;
cin>>x1>>x2;
int xx1,xx2;
if(x1[0]=='m')
xx1=1;
else if(x1[0]=='t'&&x1[1]=='u')
xx1=2;
else if(x1[0]=='w')
xx1=3;
else if(x1[0]=='t')
xx1=4;
else if(x1[0]=='f')
xx1=5;
else if(x1[0]=='s'&&x1[1]=='a')
xx1=6;
else
xx1=7;
if(x2[0]=='m')
xx2=1;
else if(x2[0]=='t'&&x2[1]=='u')
xx2=2;
else if(x2[0]=='w')
xx2=3;
else if(x2[0]=='t')
xx2=4;
else if(x2[0]=='f')
xx2=5;
else if(x2[0]=='s'&&x2[1]=='a')
xx2=6;
else
xx2=7;
int i,j;
for(i=1;i<=11;i++)
{
int d=xx1;
for(j=1;j<=a[i];j++)
d=d%7+1;
if(d==xx2)
{
printf("YES\n");
return 0;
}
}
printf("NO\n");
return 0;
}