传送门

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

  

 

Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)的更多相关文章

  1. Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort(暴力)

    传送门 Description You are given a table consisting of n rows and m columns. Numbers in each row form a ...

  2. CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

    1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组, ...

  3. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题

    A. Checking the Calendar 题目连接: http://codeforces.com/contest/724/problem/A Description You are given ...

  4. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C.Ray Tracing (模拟或扩展欧几里得)

    http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射 ...

  5. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation (非官方贪心解法)

    题目链接:http://codeforces.com/contest/724/problem/E 题目大意: 有n个城市,每个城市有pi件商品,最多能出售si件商品,对于任意一队城市i,j,其中i&l ...

  6. 贪心+树状数组维护一下 Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) D

    http://codeforces.com/contest/724/problem/D 题目大意:给你一个串,从串中挑选字符,挑选是有条件的,按照这个条件所挑选出来的字符集合sort一定是最后选择当中 ...

  7. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation 动态规划

    E. Goods transportation 题目连接: http://codeforces.com/contest/724/problem/E Description There are n ci ...

  8. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) D. Dense Subsequence 暴力

    D. Dense Subsequence 题目连接: http://codeforces.com/contest/724/problem/D Description You are given a s ...

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing 数学

    C. Ray Tracing 题目连接: http://codeforces.com/contest/724/problem/C Description oThere are k sensors lo ...

随机推荐

  1. 高性能JavaScript 循环语句和流程控制

    前言 上一篇探讨了达夫设备对于代码性能的影响,本文主要探讨并且测试各种常见的循环语句的性能以及流程控制中常见的优化. 循环语句 众所周知,常用的循环语句有for.while.do-while以及for ...

  2. 各地IT薪资待遇讨论

    作为一个搞.net开发的程序员,在北京混了三年半,最近准备辞职到上海找工作.由于对上海的IT行业还不是很了解,在这里想让上海的同行们说下你们的情况,以方便我对自己在上海的定位,当然,其余城市的的同行们 ...

  3. Ext.NET-基础篇

    概述 本文介绍Ext.NET的基本概念,安装配置.布局以及容器,最后介绍了DirectEvents.DirectMethod.Listener,并提供了示例代码. 示例代码下载地址>>&g ...

  4. Android音频播放之SoundPool

    SoundPool 一.基本概念 在Android应用程序的开发过程中,经常需要播放多媒体文件,也许最先想到的会是MediaPlayer类了,该类提供了播放.暂停.停止及重复播放等功能性方法(该类位于 ...

  5. 构建Spark的Eclipse开发环境

    前言 无论Windows 或Linux 操作系统,构建Spark 开发环境的思路一致,基于Eclipse 或Idea,通过Java.Scala 或Python 语言进行开发.安装之前需要提前准备好JD ...

  6. windows注册表学习笔记

    注册表,想起来了就学学,方便操作.无需把它当成重要学问,今日就学一波,作为了解. 一.注册表清理脚本 主要是删除临时文件,旧文件.并不能够删除无效的键 @echo off del/f/s/q %sys ...

  7. The median of multi ascending array

    Given 17 arrays,every array is ascending.The task is to get the median of all these numbers. 0 1 2 3 ...

  8. 品牌OEM信息导入工具(实测支持Win10)

    OEM修改,定制专属LOGO. 免费下载:http://yunpan.cn/cmZuTYWLIGX6Q  访问密码 2da7 备用通道:            http://pan.baidu.com ...

  9. 0930MySQL中实现高性能高并发计数器方案(例如文章点击数)

    转自http://www.jb51.net/article/56656.htm 这篇文章主要介绍了MySQL中实现高性能高并发计数器方案,本文中的计数器是指如文章的点击数.喜欢数.浏览次数等,需要的朋 ...

  10. Maven的内置变量

    Maven内置变量说明: ${basedir} 项目根目录(即pom.xml文件所在目录) ${project.build.directory} 构建目录,缺省为target目录 ${project. ...