codeforces724-A. Checking the Calendar 日期题
首先有这样一个显然的事实,那就是每个月的第一天可以是星期x,x可以取遍1~7
因为日期一直在往后退,总有一年能轮到分割线那天,因为本来其实压根就没有月份的划分,月份划分是人为的
而且我们也不知道开始的时候是从啥时候开始,开始时是星期几,所以也可以大胆假设,
并且要注意题目中没有闰年的这个条件,很重要。。
打代码还遇到一些坑,写到注释里了
string的读入与printf调试的矛盾一直没解决
#include <cstring>
#include <cstdio>
#include <iostream>
//要想使用string 必须包含iostream文件
//否则就会报错
using namespace std;
int monthday[]={,, , , , , , , , , , , };
string name[]={"","monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
//少加了分号,很伤
int get_Index(string p){
register int i;
for(i=;i<=;++i){
if(p==name[i]){
return i;
}
}
}
char a[],b[];
//读取string 是一个问题
int main(){
scanf("%s%s",a,b);
string p[];
int index[];
p[]=string(a);//本构造函数长期有效
p[]=string(b);//变量赋值前面不加类型,很伤
index[]=get_Index(p[]);
index[]=get_Index(p[]);
//printf("index %d %d\n",index[0],index[1]);
register int i,j;
for(j=;j<=;++j){
int temp=index[];
for(i=;i<=monthday[j];++i){//++i 写成 ++j
temp++;
if(temp>) temp-=;
}
if(temp==index[]){
printf("YES\n");
return ;
}
}
printf("NO\n");
return ;
}
codeforces724-A. Checking the Calendar 日期题的更多相关文章
- 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 ...
- Checking the Calendar
Checking the Calendar time limit per test 1 second memory limit per test 256 megabytes input standar ...
- java成神之——date和calendar日期的用法
date和calendar日期的用法 util的data转换成sql的data 创建Date对象 格式化 Instant ChronoUnit LocalTime LocalDate LocalDat ...
- 【C#】wpf自定义calendar日期选择控件的样式
原文:[C#]wpf自定义calendar日期选择控件的样式 首先上图看下样式 原理 总览 ItemsControl内容的生成 实现 界面的实现 后台ViewModel的实现 首先上图,看下样式 原理 ...
- 8.算法竞赛中的常用JAVA API :Calendar日期类
8.算法竞赛中的常用JAVA API :Calendar日期类 摘要 在蓝桥杯中有关于日期计算的问题,正好java中的Date类和Calendar类提供了对日期处理的一些方法.Date类大部分方法已经 ...
- 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 ...
- 求大神帮解答calendar日期插件的问题
小颖最近公司的项目里用了一款日期插件 calendar.js 但是在用的过程中遇到了难题,就是当日期只需要选择具体的月份就可以了,不需要再选具体日期时,小颖解决不了,只能让它默认显示出月份,但是月 ...
- Educational Codeforces Round 13 B. The Same Calendar 水题
B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...
- Calendar 日期类介绍
Calendar c = Calendar.getInstance();//创建实例 默认是当前时刻 c.get(Calendar.YEAR); c.get(Calendar.MONTH); c.ge ...
随机推荐
- iOS CoreData relationship 中的inverse
官方文档建议为每一个可以设置inverse的relationship设置一个inverse.目的是保持数据库的正确性.但是没有具体的说明. 我在stackoverflow中找到了一个是分好的答案,ht ...
- [转]Android中Application类的用法
原文链接:http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.html Application类 Application ...
- C#字符串的四舍五入
Round(Decimal) Round(Double) Round(Decimal, Int32) Round(Decimal, MidpointRounding) Round(Double, In ...
- 用户登录流程详解 +volley(StringRequest)
在实习期间由于要求使用volley,所以第一次开始接触volley,从一开始的迷茫陌生,到疯狂的查找各种资料,通过在项目中用到的实际问题,我想做一些总结,所以写了这篇文章.下面我将介绍我理解的用户登录 ...
- 【python】解压文件
参考:http://essen.iteye.com/blog/1941489 tarfile模块 具体使用方法: https://docs.python.org/2/library/tarfile.h ...
- Java反射实战
一.背景 最近的项目中需要使用到Java 反射的知识,以前不怎么了解,也基本没怎么用过,抽出一片时间,来具体学习和实战下Java的反射!拿来和大家分享以及记录方便以后学习! 二.反射相关概念解析 1. ...
- 阿里云ecs Linux平台安装mongodb数据库
MongoDB提供了linux平台上32位和64位的安装包,你可以在官网下载安装包. 下载地址:http://www.mongodb.org/downloads 下载完安装包,并解压 tgz(以下演示 ...
- 比较原声socket 、GCDAsyncSocket
原声socket NSInputStream 输入流(OC)NSOutputStream 输出流(OC)1:通过c语言的输入输出流CFReadStreamRef/CFWirteStreamRef(输入 ...
- Java使用正则表达式解析LRC歌词文件
LRC歌词是一种应用广泛的歌词文件,各主流播放器都支持. lrc歌词文本中含有两类标签: 1.标识标签(ID-tags) [ar:艺人名] [ti:曲名] [al:专辑名] [by:编者(指编辑LRC ...
- mybatis 学习!
参考链接 http://www.mybatis.org/spring/zh/mappers.html http://www.cnblogs.com/fangjian0423/p/spring-myba ...