【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,将当前的字符数量翻倍花费 ...
随机推荐
- 【零基础入门学习Python笔记012】一个打了激素的数组3
列表的一些经常使用操作符 比較操作符 逻辑操作符 连接操作符 反复操作符 成员关系操作符 +表示两个连接.*表示复制. list中"+"两边的类型必须一致. 演示样例: water ...
- 如何获取用户的地理位置-浏览器地理位置(Geolocation)API 简介
如何获取用户的地理位置-浏览器地理位置(Geolocation)API 简介 一.总结 一句话总结:Geolocation API(地理位置应用程序接口)提供了一个可以准确知道浏览器用户当前位置的方法 ...
- 关于C语言的书
我想横着走,,哈哈哈哈
- [NIO]用dawn发送接收HTTP请求
HTTP协议的下层使用的是tcp.所以我们建立一个tcp连接就能发送接收http请求.dawn底层使用了nio.可是经过dawn的封装之后,我们在编写代码的时候,就和使用普通的堵塞式socket一样 ...
- android 应用内部获取本应用或者相应包名的应用的SHA1签名的办法
我这个人比較懒.每次做的都是心血来潮,所以打算改掉这个坏毛病.昨晚非常晚才睡,躺在床上一直在回忆.这两年来,我以前的目标是什么,我放弃了什么,我完毕了什么. 结果目标非常多,也放弃了一些. 完毕的差点 ...
- jdbc之二:DAO模式 分类: B1_JAVA 2014-04-29 15:13 1536人阅读 评论(0) 收藏
详细代码请参见 https://github.com/lujinhong/dao 一.前期准备 1.创建数据库 create database filter_conf; 2.创建表并插入数据 crea ...
- Python 标准库和第三方库的安装位置、Python 第三方库安装的各种问题及解决
首先使用 sys 下的 path 变量查看所有的 python 路径: import sys sys.path 标准库 lib 目录下(home 目录/pythonXX.XX/lib) 第三方库 在 ...
- 嵌入式平台下的ldd
x86平台有ldd可以很方便的查看对库的依赖关系,但在嵌入式linux环境中没有这个命令,替而代之是 CC=$(CROSS_COMPILE)gcc LDD=$(CROSS_COMPILE)readel ...
- C# datatable增加行(datarow)数据为另一个datatable中某行
两个表A和B,两表结构相同.现在需要将A表中部分行拷贝到B表中,直接用 DataTableB.rows.add(dataTableA.rows[0]) 这样的方法式会报"row已经属于A表& ...
- 多校第六场 HDU 4927 JAVA大数类+模拟
HDU 4927 −ai,直到序列长度为1.输出最后的数. 思路:这题实在是太晕了,比赛的时候搞了四个小时,从T到WA,唉--对算组合还是不太了解啊.如今对组合算比較什么了-- import java ...