【63.63%】【codeforces 724A】Checking the Calendar
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的更多相关文章
- 【 BowWow and the Timetable CodeForces - 1204A 】【思维】
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...
- 【63.73%】【codeforces 560A】Currency System in Geraldion
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【11.61%】【codeforces 670F】Restore a Number
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【搜索】【并查集】Codeforces 691D Swaps in Permutation
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
- 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【链表】【模拟】Codeforces 706E Working routine
题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...
- 【动态规划】【最短路】Codeforces 710E Generate a String
题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费 ...
随机推荐
- HDU2438 Turn the corner【三分法】【数学几何】
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- boost 库编译选项
boost大部分库仅仅须要包括头文件就可以使用,而有部分须要编译的.例如以下: E:\Qt\Qt3rdlib\boost_1_58_0>bjam --show-libraries The fol ...
- Android 利用an框架快速实现夜间模式的两种套路
作者:Bgwan链接:https://zhuanlan.zhihu.com/p/22520818来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 网上看到过大多实现夜间模 ...
- 【2024】求X到Y之间的整数和
Time Limit: 3 second Memory Limit: 2 MB [问题描述] 计算X到Y之间的整数和(要求用函数实现).注意输入时X不一定小于Y,且X.Y不一定都是整数. [输入] 两 ...
- [Recompose] Add Lifecycle Hooks to a Functional Stateless Component using Recompose
Learn how to use the 'lifecycle' higher-order component to conveniently use hooks without using a cl ...
- [Elm] Installing and setting up Elm
Before writing any Elm we need to first install the runtime locally. In this lesson we install the E ...
- 小雷FansUnion:我有了第一个付费客户(第一个徒弟)
很高兴地告诉大家一个振奋人心的消息,我刚刚拥有了第一个付费客户. 第一个付费客户是山东青岛的一个上班族,有2年.Net经验,今年转Java开发.对我比较信任,在我的建议下,选择了"拜师学艺& ...
- js进阶正则表达式13RegExp对象方法(RegExp对象的方法:compile,test,exec)(子表达式 var reg1=/([a-z]+)\d/)
js进阶正则表达式13RegExp对象方法(RegExp对象的方法:compile,test,exec)(子表达式 var reg1=/([a-z]+)\d/) 一.总结 1.RegExp对象有三个方 ...
- Android Error:(1,N1) 错误: 需要class, interface或enum
造成这个error的原因是Java文件编码格式不对, 比如可能是你之前这个文件是用GBK写的,后来复制到utf-8环境里编译,而文件里有些是隐藏的字符,很难找出来的. 解决方法是在Notepad++新 ...
- Android 自动弹出软键盘(输入键盘)
很多应用中对于一个界面比如进入搜索界面或者修改信息等等情况,为了用户体验应该自动弹出软键盘而不是让用户主动点击输入框才弹出(因为用户进入该界面必然是为了更改信息).具体实现这种效果如下: EditTe ...