【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,将当前的字符数量翻倍花费 ...
随机推荐
- 【Eclipse提高开发速度-插件篇】Checkstyle的使用
1.CheckStyle是SourceForge下的一个项目,提供了一个帮助JAVA开发者遵守某些编码规范的工具. CheckStyle提供了大部分功能都是对于代码规范的检查 CheckStyle检验 ...
- 基于bootstrap的主流框架有哪些
基于bootstrap的主流框架有哪些 一.总结 一句话总结:其实可以直接百度bootstrap后台模板,出来一大堆,想用哪个用哪个. 二.[前端框架系列]浅谈当前基于bootstrap框架的几种主流 ...
- 动词 + to do、动词 + doing
1. 含义有重大区别 动词+to do 与 动词 + doing,具有较大含义上的差别的动词主要有: stop finish forget 在这些单词的后面,自然 to do 表示未做的事,doing ...
- 将html转换为word文档的几种方式
1 基于wps直接将页面信息下载成word文档 public void test() { WPS.Application wps = null; try { wps = new WPS.Applica ...
- 3、C++快速入门
参考书籍: C++程序设计教程_第二版_钱能 //篇幅较少,适合快速学习 C++ Primer Plus 第六版 中文版 //篇幅较大,讲的非常详细 C++一般必须包含的头文件是#inc ...
- 126邮件POP3,SMTP服务器与端口设置
- hive SQL优化之distribute by和sort by
近期在优化hiveSQL. 以下是一段排序,分组后取每组第一行记录的SQL INSERT OVERWRITE TABLE t_wa_funnel_distinct_temp PARTITION (pt ...
- u3d demo起步第二章
假设要给一个角色加入寻路组件.那么仅仅须要选中这个角色,Component->Navigation->Nav Mesh Agent就能够加入寻路组件. 然后仅仅要agent.SetDest ...
- perl对比两个文件的行
perl对比两个文件的行 对比两个文件的各行,得到A与B相同的行/A与B不相同的行 主要功能 得到相同行 得到A中包含,B不包含的行 得到B中包含,A中不包含的行 具体执行情况 Perl代码 #!/u ...
- 撸代码--类QQ聊天实现(基于linux 管道 信号 共享内存)
一:任务描写叙述 A,B两个进程通过管道通信,像曾经的互相聊天一样,然后A进程每次接收到的数据通过A1进程显示(一个新进程,用于显示A接收到的信息),A和A1间的数据传递採用共享内存,相应的有一个B1 ...