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).

Examples
input
monday
tuesday
output
NO
input
sunday
sunday
output
YES
input
saturday
tuesday
output
YES
Note

In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.

In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.

题意:给我两个日期表示星期几,现在问,如果一个月的一号是前一个数,那么下一个月的一号是不是后面一个数字

解法:不计闰年,那么把这一个月所有可能的天数都加一下%7,看余数是不是后面一个数字

#include <bits/stdc++.h>
using namespace std;
int main(){
string s1,s2;
map<string,int>v;
v["monday"]=1;
v["tuesday"]=2;
v["wednesday"]=3;
v["thursday"]=4;
v["friday"]=5;
v["saturday"]=6;
v["sunday"]=0;
cin>>s1>>s2;
int flag=0,a=v[s1],b=v[s2];
if((a+28)%7==b || (a+30)%7==b || (a+31)%7==b) flag=1;
if(flag) cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

  

Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A的更多相关文章

  1. 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的数组, ...

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

    传送门:D Dense Subsequence 题意:输入一个m,然后输入一个字符串,从字符串中取出一些字符组成一个串,要求满足:在任意长度为m的区间内都至少有一个字符被取到,找出所有可能性中字典序最 ...

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

    链接 题意:输入n,m,表示一个n行m列的矩阵,每一行数字都是1-m,顺序可能是乱的,每一行可以交换任意2个数的位置,并且可以交换任意2列的所有数 问是否可以使每一行严格递增 思路:暴力枚举所有可能的 ...

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

    我不告诉你这个链接是什么 分析:模拟可以过,但是好烦啊..不会写.还有一个扩展欧几里得的方法,见下: 假设光线没有反射,而是对应的感应器镜面对称了一下的话 左下角红色的地方是原始的的方格,剩下的三个格 ...

  5. 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个点,求射 ...

  6. 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 ...

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

    传送门 Description You are given names of two days of the week. Please, determine whether it is possibl ...

  8. 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 ...

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

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

随机推荐

  1. 【Origin】 破阵子-未可留 征人调

    几朝岁月,悠悠,容颜改,两鬓衰,可恨荣光不留! 一生事,忧心畔,可怜惶惶,不拿年岁当缠头: 只把扑朔往往,人生几回首: 等闲识得料峭处,一腔泪流: 曾记否,三十功名尘与土,不可解忧愁: 青春换得明日花 ...

  2. SQL 面向对象(委托)

    委托:也称为代理,事件也是一种委托:定义在类的最外面 1.定义委托关键字:delegate函数签名:签名和函数保持一致定义委托的时候要根据函数来定义public delegate int First( ...

  3. php session 跨子域和跨服务器解决方式

    Session主要分两部分:    一个是Session数据,该数据默认情况下是存放在服务器的tmp文件下的,是以文件形式存在     另一个是标志着Session数据的Session Id,Sess ...

  4. 夺命雷公狗---node.js---7fs模块初步

    目录结构如下所示: /** * Created by leigood on 2016/8/13. */ var http = require("http"); var fs = r ...

  5. 夺命雷公狗ThinkPHP项目之----企业网站6之栏目的添加(主要用模型来验证字段)

    我们刚才的控制器已经写好了,那么我们现在就来完成我们的模型, 首先我们在Model目录下创建一个CategoryModel.class.php 代码如下: <?php namespace Adm ...

  6. [tp3.2.1]开启URL(重写模式),省略URL中的index.php

    重写模式(省略url中的index.php) 在apache配置文件httpd.conf中,查找 1.mod_rewrite.so, 启动此模块 2.AllowOverride , 值= All 3. ...

  7. ADO.NET中的TransactionScope何时需要启用MSTDC(分布式事务管理)

    我们知道在ADO.NET中可以用TransactionScope来将多个SqlConnection(多个数据库连接)执行的Sql语句放入一个事物中提交或取消,但是使用TransactionScope的 ...

  8. Java如何对ArrayList里的元素排序

  9. Android中ListView放入PopupWindow产生问题解决

    今天在做项目时候发现将ListView放入PopupWindow产生问题,ListView放入PopupWindow后 对PopupWindow设置了setFocusable(true)这时候其他的控 ...

  10. dubbo 学习

    1. dubbo Can not lock the registry cache file: 当本地同时启动服务端和客户端的时候就可能产生这个问题. 解决方案 Dubbo通过注册中心发现服务,发现的服 ...