Codeforces Round Intel Code Challenge Final Round A.Checking the Calendar

题目大意:问你是否存在一个非闰年,使得某个月的开始为第一行所给的星期,下一个月开始为第二行所给的星期


直接模拟即可。

或者因为每个月天数固定,所以只需要考虑特定的几种情况


#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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值