A. Checking the Calendar

题目连接:

http://codeforces.com/contest/724/problem/A

Description

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

monday

tuesday

Sample Output

NO

Hint

题意

给你两个星期几,然后问你可不可能这个月的一号是第一个星期,下个月的一号是第二个星期。

题解:

暴力模拟就好了嘛

水题

代码

#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");
}

Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题的更多相关文章

  1. CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

    1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组, ...

  2. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)D Dense Subsequence

    传送门:D Dense Subsequence 题意:输入一个m,然后输入一个字符串,从字符串中取出一些字符组成一个串,要求满足:在任意长度为m的区间内都至少有一个字符被取到,找出所有可能性中字典序最 ...

  3. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort

    链接 题意:输入n,m,表示一个n行m列的矩阵,每一行数字都是1-m,顺序可能是乱的,每一行可以交换任意2个数的位置,并且可以交换任意2列的所有数 问是否可以使每一行严格递增 思路:暴力枚举所有可能的 ...

  4. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing

    我不告诉你这个链接是什么 分析:模拟可以过,但是好烦啊..不会写.还有一个扩展欧几里得的方法,见下: 假设光线没有反射,而是对应的感应器镜面对称了一下的话 左下角红色的地方是原始的的方格,剩下的三个格 ...

  5. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C.Ray Tracing (模拟或扩展欧几里得)

    http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射 ...

  6. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation (非官方贪心解法)

    题目链接:http://codeforces.com/contest/724/problem/E 题目大意: 有n个城市,每个城市有pi件商品,最多能出售si件商品,对于任意一队城市i,j,其中i&l ...

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

  8. Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort(暴力)

    传送门 Description You are given a table consisting of n rows and m columns. Numbers in each row form a ...

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B

    Description You are given a table consisting of n rows and m columns. Numbers in each row form a per ...

  10. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A

    Description You are given names of two days of the week. Please, determine whether it is possible th ...

随机推荐

  1. bzoj千题计划205:bzoj3529: [Sdoi2014]数表

    http://www.lydsy.com/JudgeOnline/problem.php?id=3529 有一张n*m的数表,其第i行第j列(1 < =i < =n,1 < =j & ...

  2. java.uti.Random类nextInt方法中随机数种子为47的奇怪问题

    一,问题描述 需要生成一个[0,1]的随机数.即随机生成 0 或者 1.使用java.util.Random类的 nextInt(int)方法,当构造Random类的对象并提供随机数种子时,发现了一个 ...

  3. js 正则之 检测素数

    相信很多人应该看过这篇文章,我第一次看到的时候是11年的样子,那时候学vbs的时候看过这个问题.原文<检查素数的正则表达式>,在文章里已经解释了他是怎么判断的,我就不啰嗦了.我们来说说 j ...

  4. 一些js的小技巧

    这里收集了一些编码上的小技巧,大家可以学习学习. 1.浮点转整型 使用|0快速转换 var a=(12.002)|0;//12 使用~~快速转换 ~取反运算符,2=0010,~2=1101,因为第一位 ...

  5. Metasploit输出重定向到文件

    Metasploit是我们经常会使用到的神器,但是运行exploit/run无法保存输出信息,查看不是很方便. 现在可以使用spool来保存输出信息: Metasploit Framework Con ...

  6. kali更新失败

    今天更新kali时失败,出现如下问题: root@kali:~# apt-get update Get: http://mirrors.aliyun.com/kali kali-rolling InR ...

  7. CF11D A Simple Task(状压DP)

    \(solution:\) 思路大家应该都懂: 状压DP:\(f[i][j]\),其中 \(i\) 这一维是需要状压的,用来记录19个节点每一个是否已经走过(走过为 \(1\) ,没走为 \(0\) ...

  8. 【比赛游记】NOIP2017游记

    身为FJ的选手,在师大附中AHSOFNU考试,环境很不错,考得也还可以吧...[考的并不好] 不过比赛前都在划水233333 另:看到这篇博客的OIer们一定要评论啊! Day1的中午,因为穿了短袖去 ...

  9. 有用的linux命令集锦

    http://blog.csdn.net/hackerain/article/details/7946193 1. 查看内存使用情况 free -m 2. 查看系统版本信息 sudo lsb_rele ...

  10. mysql学习------权限机制

    MySQL服务器通过MySQL权限表来控制用户对数据库的访问,MySQL权限表存放在mysql数据库里,由mysql_install_db脚本初始化.这些MySQL权限表分别user,db,table ...