Checking the Calendar
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard 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.

分析:取差之后看能否满足即可;

代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
const int maxn=1e5+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
inline ll read()
{
ll x=;int f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n,m,k,t,c[]={, , , , , , , , , , , };
char a[maxn],b[maxn];
map<string,int>d;
int main()
{
int i,j;
d["monday"]=;
d["tuesday"]=;
d["wednesday"]=;
d["thursday"]=;
d["friday"]=;
d["saturday"]=;
d["sunday"]=;
scanf("%s%s",a,b);
int co=(d[b]-d[a]+)%;
rep(i,,)
{
if(c[i]%==co)return *puts("YES");
}
puts("NO");
//system("Pause");
return ;
}

Checking the Calendar的更多相关文章

  1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题

    A. Checking the Calendar 题目连接: http://codeforces.com/contest/724/problem/A Description You are given ...

  2. Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)

    传送门 Description You are given names of two days of the week. Please, determine whether it is possibl ...

  3. 【63.63%】【codeforces 724A】Checking the Calendar

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. codeforces724-A. Checking the Calendar 日期题

    首先有这样一个显然的事实,那就是每个月的第一天可以是星期x,x可以取遍1~7 因为日期一直在往后退,总有一年能轮到分割线那天,因为本来其实压根就没有月份的划分,月份划分是人为的 而且我们也不知道开始的 ...

  5. Java中的Calendar日历用法详解

    第一部分 Calendar介绍 public abstract class Calendar implements Serializable, Cloneable, Comparable<Cal ...

  6. Java Calendar,Date,DateFormat,TimeZone,Locale等时间相关内容的认知和使用(1) Calendar

    Java 操作日期/时间,往往会涉及到Calendar,Date,DateFormat这些类. 最近决定把这些内容系统的整理一下,这样以后使用的时候,会更得心应手.本章的内容是主要讲解“Java时间框 ...

  7. codeforces 724

    题目链接: http://codeforces.com/contest/724 A. Checking the Calendar time limit per test 1 second memory ...

  8. PMP模拟考试-1

    1. A manufacturing project has a schedule performance index (SPI) of 0.89 and a cost performance ind ...

  9. Codeforces Gym101522 D.Distribution of Days-算日期 (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)

    D.Distribution of Days The Gregorian calendar is internationally the most widely used civil calendar ...

随机推荐

  1. AVFoundation--AVCaptureSession

    // // ViewController.m // AVFountionCamera // // Created by ZhuYi on 16/5/3. // Copyright © 2016年 DD ...

  2. sql 多个字段排序,头一个字段排序完,再对第二个字段进行排序(以此类推)

    现根据num排序,num数字相同的根据时间进行排序,都是降序DESC SELECT * FROM counts ORDER BY num DESC,create_time DESC

  3. POJ 3537 Crosses and Crosses(SG/还未想完全通的一道SG)

    题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; ]; ...

  4. UltraEdit 中的常用正则表达式

    正则表达式 (UltraEdit Syntax):   % 匹配行首 - 表明要搜索的字符串一定在行首.   $ 匹配行尾 - 表明要搜索的字符串一定在行尾   ? 匹配除换行符外的任一单个字符.   ...

  5. Vultr优惠码20美元享受20GB SSD和2T流量

    美国vps主机商vultr最新优惠码:20FOR30,只限新注册用户,点击注册链接,进入后台Billing,找到Gift code,输入20FOR30,点击apply,就能免费获得20美元的账户余额. ...

  6. 第二次冲刺spring会议(第四次会议)

    [例会时间]2014/5/7 21:15 [例会地点]9#446 [例会形式]轮流发言 [例会主持]马翔 [例会记录]兰梦 小组成员:兰梦 ,马翔,李金吉,赵天,胡佳奇

  7. Objective-C中关于请求返回NSData数据解析成NSDictionary或NSArray的方法

    1.如果后台返回的是字典或数组的data型,直接使用以下方法转换: { // Data 转成 字典 其中responseObject为返回的data数据 NSDictionary *resultDic ...

  8. C - 小Y上学记——认识新同学

    C - 小Y上学记——认识新同学 Time Limit: 4000/2000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others) ...

  9. 关于oracle数据库(7)查询1

    查询所有列数据 select * from 表名; 查询指定列数据 效率高于查询所有列数据 select 列名,列名,列名 from 表名; --先执行from后面的代码,找到表,在执行select后 ...

  10. 如何通过Maven的Tomcat插件运行Web工程

    去tomcat官网http://tomcat.apache.org/,左侧栏Apache Tomcat下的Maven Plugin,点进去选择最新版本Version 2.2 通过介绍可知,使用tomc ...