传送门

Description

You are given names of two days of the week.

Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.

In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.

Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Input

The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Output

Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).

Sample Input

mondaytuesday
sundaysunday
saturdaytuesday

Sample Output

NO

YES

YES

思路

题意:给出一星期中的两天,问他们有没有可能是平年中连续的两个月的头一天。

注意tuesday thursday和thursday tuesday不是同种情况就可以了。

 
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int x,y;
	int a[5] = {29,31,32};
	string str1,str2;
	cin >> str1 >> str2;
	if (str1 == "monday")	x = 1;		if (str2 == "monday")	y = 1;
	if (str1 == "tuesday")	x = 2;		if (str2 == "tuesday")	y = 2;
	if (str1 == "wednesday")	x = 3;	if (str2 == "wednesday")	y = 3;
	if (str1 == "thursday")	x = 4;		if (str2 == "thursday")	y = 4;
	if (str1 == "friday")	x = 5;		if (str2 == "friday")	y = 5;
	if (str1 == "saturday")	x = 6;		if (str2 == "saturday")	y = 6;
	if (str1 == "sunday")	x = 7;		if (str2 == "sunday")	y = 7;
	bool flag = false;
	if (y >= x)
	{
		for (int i = 0;i < 3;i++)
		{
			if (a[i] % 7 == y - x + 1)
			{
				flag = true;
				break;
			}
		}
		if (flag)	printf("YES\n");
		else	printf("NO\n");
	}
	else
	{
		for (int i = 0;i < 3;i++)
		{
			if (a[i] % 7 == 7 - x + 1 + y)
			{
				flag = true;
				break;
			}
		}
		if (flag)	printf("YES\n");
		else	printf("NO\n");
	}
	return 0;
}

  

 

最新文章

  1. ASP.NET中控件命名规则
  2. MacBook下如何安装mysql-python
  3. 画廊插件baguetteBox
  4. 2.10 用最少次数寻找数组中的最大值和最小值[find min max of array]
  5. python生成验证码脚本
  6. Android 使用WakeLock
  7. Swift - 正则表达式的使用(附用户名、邮箱、URL等常用格式验证)
  8. 查找git ignore的追踪
  9. FALSE
  10. user story
  11. iframe页面刷新问题
  12. ASP.NET MVC学习(四)之视图View
  13. 报错:System.NotSupportedException: LINQ to Entities does not recognize the method
  14. 【Socket】linux套接字技术之tcp
  15. C艹复合类型(字符串)
  16. Win7上安装WMware虚拟机和Ubuntu操作系统
  17. 通过电机编码器AB相输出确定电机转向
  18. 2016.5.21——Compare Version Numbers
  19. CoreOS中随着系统启动Docker Container
  20. css 盒子垂直居中

热门文章

  1. C#中字典集合HashTable、Dictionary、ConcurrentDictionary三者区别
  2. 使用markdown编辑evernote(印象笔记)的常用方法汇总
  3. 用c#操作Mongodb(附demo)
  4. 2016年1月25日 《1024伐木累》-小白篇之开发网站,三天!(中篇-2奇怪的IE)-总章节十一
  5. spring配置属性的两种方式
  6. .net MVC全球化资源使用心得
  7. [团队项目]Github生成燃尽图的方式
  8. 从 Microsoft SQL Server 迁移到 Oracle
  9. android 之 surfaceView和普通View的重绘使用
  10. Linux_日志管理介绍(一)