传送门

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. struts2 Result Type四个常用转跳类型

    Result的四个常用转跳类型分别为 Dispatcher 用来转向页面,是Struts的默认形式 Redirect   重定向到一个URL Chain  用来处理Action链 RedirectAc ...

  2. JS事件详解

    hello,我是沐晴,最近呢,来总结一下 JS中的常用的事件,希望我们都能一起查漏补缺. 焦点事件 焦点事件在表单中经常用到,那什么是焦点呢?比如我们文本框里面的有光标的时候,就是获得了焦点,我们就可 ...

  3. Vue学习笔记-1

    前言 本文不是Vue.js的教程,只是一边看官网Vue的教程文档一边记录并总结学习过程中遇到的一些问题和思考的笔记. 1.vue和avalon一样,都不支持VM初始时不存在的属性 而在Angular里 ...

  4. Redis Sentinel:集群Failover解决方案(转载)

    本文转载自:http://shift-alt-ctrl.iteye.com/blog/1884370 文中的配置例子,还有failover过程中触发的订阅事件具有很好的参考价值. Redis sent ...

  5. 手机信号强度单位dB、dBm和asu

    dB.dBm都是功率增益的单位,不同之处如下: dB是一个表征相对值的值,纯粹的比值,只表示两个量的相对大小关系,没有单位,当考虑甲的功率相比于乙功率大或小多少个dB时,按下面的计算公式:10log( ...

  6. matlab 功率谱分析

    matlab 功率谱分析 1.直接法:直接法又称周期图法,它是把随机序列x(n)的N个观测数据视为一能量有限的序列,直接计算x(n)的离散傅立叶变换,得X(k),然后再取其幅值的平方,并除以N,作为序 ...

  7. LaTeX常用数学符号表示方法

    转自:http://www.mohu.org/info/symbols/symbols.htm 常用数学符号的 LaTeX 表示方法 (以下内容主要摘自“一份不太简短的 LATEX2e 介绍”) 1. ...

  8. SD卡状态广播

    SD状态发生改变的时候会对外发送广播.SD卡的状态一般有挂载.未挂载和无SD卡. 清单文件 一个广播接受者可以接受多条广播.这里在意图过滤器中添加是data属性是因为广播也需要进行匹配的.对方发送的广 ...

  9. 很简单的多线程访问python嘿嘿嘿

    import urllib import socket from threading import * url = "http://www.baidu.com/s?ie=UTF-8& ...

  10. webkit webApp 开发技术要点总结

    如果你是一名前端er,又想在移动设备上开发出自己的应用,那怎么实现呢?幸好,webkit内核的浏览器能帮助我们完成这一切.接触 webkit webApp的开发已经有一段时间了,现把一些技巧分享给大家 ...