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 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 水题的更多相关文章
- 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的数组, ...
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)D Dense Subsequence
传送门:D Dense Subsequence 题意:输入一个m,然后输入一个字符串,从字符串中取出一些字符组成一个串,要求满足:在任意长度为m的区间内都至少有一个字符被取到,找出所有可能性中字典序最 ...
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort
链接 题意:输入n,m,表示一个n行m列的矩阵,每一行数字都是1-m,顺序可能是乱的,每一行可以交换任意2个数的位置,并且可以交换任意2列的所有数 问是否可以使每一行严格递增 思路:暴力枚举所有可能的 ...
- 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 (模拟或扩展欧几里得)
http://codeforces.com/contest/724/problem/C 题目大意: 在一个n*m的盒子里,从(0,0)射出一条每秒位移为(1,1)的射线,遵从反射定律,给出k个点,求射 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- nginx php上传大文件的设置(php-fpm)
对于lnmp架构的大文件上传的问题,有几个地方需要修改,另外还有几个参数如果更改过需要注意,下面是详细的需要注意的地方: nginx的修改 send_timeout 6 ...
- 20155303 实验三 敏捷开发与XP实践
20155303 实验三 敏捷开发与XP实践 目录 一.编码标准 任务一:在IDEA中使用工具(Code->Reformate Code)格式化代码,并学习Code菜单的功能 二.敏捷开发与XP ...
- SqlMapConfig.xml全局配置文件介绍——(四)
----------mybatis的全局配置文件SqlMapConfig.xml,配置内容如下:----------- properties(属性) settings(全局配置参数) typeAlia ...
- docker之容器访问和网络连接(三)
前言 当一台服务器上部署了多个应用容器,它们直接可能需要相互通信,比如web应用容器需要访问mysql数据库容器. 主机访问容器 通过映射端口的形式我们可以在外部访问容器内的服务 # 将主机的127. ...
- SQL Server修改默认端口号1433
方法1: 1) SqlServer服务使用两个端口:TCP-1433.UDP-1434. 其中1433用于供SqlServer对外提供服务,1434用于向请求者返回SqlServer使用了那个TCP/ ...
- grep和sed匹配多个字符关键字的用法
GNU sed和UNIX sed 写法不一样 匹配多个关键词,打印出匹配的行,效果类似于 grep grep hello\|world file > output 或者用扩展正则 grep -E ...
- plsql 查询 卡死问题解决
plsql可以连接数据库,一点查询就卡死.sqlplus可以连接数据库,也可以查询.后经过测试,原来plsql所引用的路由器ip和服务器ip有限制,修改同一网段ip问题解决.但是不知为何不同网段ip可 ...
- php ++测试
2014年4月27日 12:17:47 结论暂时没有组织语言去表述,但是看看测试结果大家都会明白的 $x = 1; $y = empty($x) ? 3 : $x++; var_dump($x,$y) ...
- Java工具库:
1. 重试框架: https://docs.spring.io/spring-batch/trunk/reference/html/retry.html <dependency> < ...
- 使用css实现移动端导航条滚动
<div class="tab"> <div class="table-item"> <span class="tab- ...