Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题
2016-10-09 13:22
459 查看
A. Checking the Calendar
题目连接:
http://codeforces.com/contest/724/problem/ADescription
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).Sample Input
mondaytuesday
Sample Output
NOHint
题意
给你两个星期几,然后问你可不可能这个月的一号是第一个星期,下个月的一号是第二个星期。题解:
暴力模拟就好了嘛水题
代码
#include<bits/stdc++.h> using namespace std; int m[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31}; int getid(string s) { if(s[0]=='m')return 0; if(s[0]=='t'&&s[1]=='u')return 1; if(s[0]=='w')return 2; if(s[0]=='t'&&s[1]=='h')return 3; if(s[0]=='f')return 4; if(s[0]=='s'&&s[1]=='a')return 5; if(s[0]=='s')return 6; } string s1,s2; int main() { cin>>s1>>s2; int p=getid(s1),q=getid(s2); for(int i=0;i<7;i++) { int now=i; for(int j=0;j<12;j++) { for(int k=0;k<m[j];k++) { now=(now+1)%7; if(k==0&&now==p&&(now+m[j])%7==q) return puts("YES"); } } } printf("NO"); }
相关文章推荐
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)A. Checking the Calendar
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) -- A. Checking the Calendar(思路)
- Codeforces Round Intel Code Challenge Final Round A.Checking the Calendar
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)【A,B,C,D】
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort 暴力
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) -- C. Ray Tracing(STL乱搞)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing 模拟
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) D题
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A. Broken Clock 水题
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) D. Dense Subsequence 贪心 + RMQ