CodeForces
来源:互联网 发布:dd是什么意思网络用语 编辑:程序博客网 时间:2024/06/06 00:17
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".
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".
Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).
mondaytuesday
NO
sundaysunday
YES
saturdaytuesday
YES
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.
//// Created by liyuanshuo on 17-3-5.//#include <iostream>using namespace std;/*enum WeekDay{monday,tuesday,wednesday,thursday,friday,saturday,sunday};*/string string1[7] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };int TurnNum( string string2 ){for (int i = 0 ; i <7 ; ++i){if( string2 == string1[i] )return i;}}int main6( ){//freopen("/home/liyuanshuo//ClionProject/C4Practice1/in.in", "r", stdin);string s1, s2;cin>>s1>>s2;int num = TurnNum(s2) - TurnNum(s1);if ( num < 0 )num += 7 ;//cout<<TurnNum(s1)<<":::"<<TurnNum(s2)<<endl;//cout<<num<<endl;if ( num == 0 || num == 2 || num == 3 )cout<<"YES"<<endl;elsecout<<"NO"<<endl;return 0;}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 汉诺塔算法解析
- hdu4825 Xor Sum【Trie、Xor】
- Machine Learning Diagnostic
- linux动态链接库导出函数控制
- python中的面向对象
- CodeForces
- 需求分析的图形工具(层次方框 warnier IPO)
- Butterknife 8.4.0版本的使用:
- hdu4292
- Linux 如何打开端口
- C++Primer第五版 第十三章习题答案(1~10)
- ext4_mpage_readpages
- poj3481(通过stl中的set,以及pair和make_pair简单通过)
- POJ1064