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. [reprint]useful linux commands

    linux一说都是搞开发玩的,敲敲键盘就能完成所有的工作.其实你也可以这么玩,玩游戏的除外哦. 那我们就来侃侃如何玩,linux是命令的天下,高级的命令那是相当的多,但是我们正真用到的也就那么几个看你 ...

  2. C++之路起航——标准模板库(deque)

    deque(双端队列):http://baike.baidu.com/link?url=JTvA2cuLubptctHZwFxswvlZvxNdFOxmifsYCGLj5IZF-Tj4rbWLv8Jn ...

  3. yii遍历行下的每列数据(小1月考)

    效果图: 控制器(1种): //显示列表    public function actionList()    {        //实例化对象        $model= new Qiu();   ...

  4. 动画--过渡延迟时间 transition-delay

    transition-delay属性和transition-duration属性极其类似,不同的是transition-duration是用来设置过渡动画的持续时间,而transition-delay ...

  5. 夺命雷公狗ThinkPHP项目之----企业网站14之文章修改页的完成

    这个其实也是挺容易的,我们思路先将栏目页给遍历出来: 这里用了catTree的方法,因为我们要对遍历出来的数据进行排序的,然后来到前端进行完成列表: <!doctype html> < ...

  6. 超链接点击后不显示hover

    超链接访问过后 hover 样式就不出现了,被点击访问过的超链接样式不在具有 hover 和 active 了 解决方法:改变CSS属性的排列顺序 L-V-H-A a:link {} a:visite ...

  7. 关于centos更新后virtualbox无法使用的问题

    http://blog.csdn.net/zgglj/article/details/50325675

  8. WCF技术的不同应用场景及其实现分析

    这一篇文章,是总结一下WCF技术,以及基于这个技术发展出来的几个典型应用场景,并且我将尝试对这些不同的WCF实现的原理进行一些比较分析. 关于WCF这个技术的基本概念,如果你不是很清楚,可以参考一下有 ...

  9. android 学习随笔八(异常处理总结)

    1.在android 中开发java.net.SocketException: socket failed: EACCES (Permission denied) 报错 第一反应就是缺少网络权限,然后 ...

  10. centos 7 systemctl

    Linux Systemctl是一个系统管理守护进程.工具和库的集合,用于取代System V.service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器.通过Syst ...