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 ...
随机推荐
- MySQL ODBC 驱动安装
一.在线安装 1.yum在线安装驱动 # yum -y install unixODBC # yum -y install mysql-connector-odbc 2.配置驱动 (1)查看驱动程序相 ...
- Kotlin 语言下设计模式的不同实现
偶然在 Github 上看到 dbacinski 写的 Kotlin 语言下设计模式的不同实现(这里的不同是相对于 Java 语言的),有些实现非常好,但是有些实现的例子不是很赞同.所以自己写了 Ko ...
- Chrome插件 postman的使用方法详解!最全面的教程
一 简介 Postman 是一款功能超级强大的用于发送 HTTP 请求的 Chrome插件 .做web页面开发和测试的人员应该是无人不晓无人不用!其主要特点 特点: 创建 + 测试:创建和发送任何的H ...
- IOC创建对象的几种方式
接上一篇IOC入门 IOC创建对象的几种方式 1)调用无参数构造器 2)带参数构造器 3)工厂创建对象 工厂类:静态方法创建对象 工厂类:非静态方法创建对象 1.对之前的User类进行一些修改,加上一 ...
- 当Python与数模相遇
数模有一个题目要处理杭州自行车在每个站点可用数量和已经借出数量,这数据在www.hzbus.cn上可以获取,它是10分钟更新一次的.这些数据手动获取,需要不停的刷页面,从6:00am到9:00pm,显 ...
- phpMyAdmin setup.php脚本的任意PHP代码注入漏洞
phpMyAdmin (/scripts/setup.php) PHP 注入代码 此漏洞代码在以下环境测试通过: phpMyAdmin 2.11.4, 2.11.9.3, 2.11.9.4, ...
- 如何区分prometheus中Histogram和Summary类型的metrics?
要理解它们的区别,关键还是告业务应用. 但如何在学习时,如何区分呢? 有以下几个维度: histogram有bucket,summary在quatile. summary分位数是客户端计算上报,his ...
- 【LOJ】#2548. 「JSOI2018」绝地反击
题解 卡常卡不动,我自闭了,特判交上去过了 事实上90pts= = 我们考虑二分长度,每个点能覆盖圆的是一段圆弧 然后问能不能匹配出一个正多边形来 考虑抖动多边形,多边形的一个端点一定和圆弧重合 如果 ...
- Codeforces Round #378 (Div. 2) F - Drivers Dissatisfaction
F - Drivers Dissatisfaction 题目大意:给你n个点,m条边,每个边都有一个权重w,每条边也有一个c表示,消耗c元可以把这条边的权重减1,求最多消耗s元的最小生成树. 思路:因 ...
- CentOS 7.4 系统安装 git
CentOS 7.4 系统安装 git 一.使用 yum 安装 1.查看系统是否已经安装 git [root@localhost ~]# git --version 2.yum 安装 git [roo ...