传送门

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. Bink Player

    class CBIKMaterial { public: CBIKMaterial(); ~CBIKMaterial(); bool Init(const char *pFileName); void ...

  2. 安装Ubuntu时的硬盘分区方案

    如果你准备在硬盘里只安装Ubuntu一个操作系统的话,建议你采用一个“/”.一个“swap”和一个“/home”的三分区方案:/ :10GB-15GB.swap:物理内存小于或等于 512MB,建议分 ...

  3. Theano2.1.2-基础知识之第一步:代数

    来自:http://deeplearning.net/software/theano/tutorial/adding.html Baby Steps - Algebra 一.两个标量相加 在学习the ...

  4. DOM Element节点类型详解

    上文中我们讲解了 DOM 中最重要的节点类型之一的 Document 节点类型,本文我们继续深入,谈谈另一个重要的节点类型 Element . 1.概况 Element 类型用于表现 HTML 或 X ...

  5. linux 权限

    ls -la 查看文件 drwxr-xr-x 2 root root 4096 ...... 第一个d:代表目录:-代表文件 后面三个一组:r:读:w:写:x:执行 第一个root 代表所属用户: 第 ...

  6. python表达式操作符【学习python必知必会】

    运算符 描述 实例 yield x 生成器函数发送协议   lambda args: expression 生成匿名函数   x if y else z 三元选择表达式(c系列有的 python也要有 ...

  7. python学习笔记整理——集合 set

    python学习整理笔记--集合 set 集合的用途:成员测试和消除重复的条目,进行集合运算 注意:花括号或set()函数可以用于创建集合. 注意:若要创建一个空的集合你必须使用set(),不能用{} ...

  8. ios8调用相机报警告: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure you(转)

    我这也报了这个警告,但按他的方法并没有起作用,把写到这个地方看是否其他人用的到 错误代码:Snapshotting a view that has not been rendered results ...

  9. Vue-loader 开启压缩后的一些坑

    在使用vue-loader 配合webpack 对.vue文件进行加载的时候,如果开启了代码压缩会出来下面几种问题,做个记录. 丢失td结束标记,导致页面的布局错乱 input的属性type为text ...

  10. 在Winform中播放视频等【DotNet,C#】

    在项目中遇到过这样的问题,就是如何在Winform中播放视频.当时考察了几种方式,第一种是直接使用Windows Media Player组件,这种最简单:第二种是利用DirectX直接在窗体或者控件 ...