time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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.

【题解】



31%7=3,30%7=2,28%7=0;

所以后一天是前一天加上3,2,0的星期。

我是想说每个月的第一天在不同的年星期一到星期天都存在吧。

所以年份什么的就不用考虑了。

#include <cstdio>
#include <iostream>
#include <string> using namespace std; string s[10],s1,s2; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
s[1] = "monday";
s[2] = "tuesday";
s[3] = "wednesday";
s[4] = "thursday";
s[5] = "friday";
s[6] = "saturday";
s[7] = "sunday";
cin >> s1;
cin >> s2;
int num1, num2;
for (int i = 1; i <= 7; i++)
if (s1 == s[i])
num1 = i;
for (int i = 1; i <= 7; i++)
if (s2 == s[i])
num2 = i;
if (num2 < num1)
num2 += 7;
int temp = num2 - num1;
if (temp == 0 || temp == 2 || temp == 3)
puts("YES");
else
puts("NO");
return 0;
}

【63.63%】【codeforces 724A】Checking the Calendar的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【63.73%】【codeforces 560A】Currency System in Geraldion

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【11.61%】【codeforces 670F】Restore a Number

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【搜索】【并查集】Codeforces 691D Swaps in Permutation

    题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...

  6. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. 【链表】【模拟】Codeforces 706E Working routine

    题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...

  8. 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions

    题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...

  9. 【动态规划】【最短路】Codeforces 710E Generate a String

    题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费 ...

随机推荐

  1. Android 快速下载 Android framework 源码

    官网 Android framework源码git地址 github: https://github.com/android/platform_frameworks_base google 官方: h ...

  2. 编程——C语言的问题,比特率

    1;; bps是bits per second的缩写,是指传输速度,音乐采样速度等,表示为: 比特/秒.

  3. Surging Demo 项目之一

    原文:Surging Demo 项目之一 开发与运行环境 IDE Visual Stadio 2017/Visual Stadio 2019 Visual Stadio Core Docker 和 D ...

  4. 8.2 Android灯光系统_led_class驱动

    android-5.0.2\hardware\libhardware\include\hardware\lights.h  //系统一些宏定义 android源码只带的灯光驱动在linux内核的dri ...

  5. 【BZOJ 3172】单词

    [链接]h在这里写链接 [题意]     给你n个单词;     这n个单词组成了一篇文章;     问你每个单词在这篇文章中出现了多少次.     其中每个单词之间用一个逗号隔开->组成一篇文 ...

  6. POJ 3624 Charm Bracelet 0-1背包

    传送门:http://poj.org/problem?id=3624 题目大意:XXX去珠宝店,她需要N件首饰,能带的首饰总重量不超过M,要求不超过M的情况下,使首饰的魔力值(D)最大. 0-1背包入 ...

  7. ArcGIS IQueryFilter接口

    樱木  原文IQueryFilter 1.IQueryFilter::SubFields (1)默认值为“*”,即查询时返回整行数据,如果只需要某一个字段数据(比如“Country”字段),则可以指定 ...

  8. Nginx content cache Nginx内容缓存

    原文地址:http://nginx.com/resources/admin-guide/caching/ Nginx content cache Nginx内容缓存 This chapter desc ...

  9. php 小程序获取渠道二维码 保存

    function ppost($url,$arr){ $post_data = json_encode($arr); $url=$url; $ch = curl_init(); curl_setopt ...

  10. 在vue中使用nprogress

    NProgress的官网:http://ricostacruz.com/nprogress/        源码地址:https://github.com/rstacruz/nprogress 1.安 ...