首先有这样一个显然的事实,那就是每个月的第一天可以是星期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 日期题的更多相关文章

  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. Checking the Calendar

    Checking the Calendar time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. java成神之——date和calendar日期的用法

    date和calendar日期的用法 util的data转换成sql的data 创建Date对象 格式化 Instant ChronoUnit LocalTime LocalDate LocalDat ...

  4. 【C#】wpf自定义calendar日期选择控件的样式

    原文:[C#]wpf自定义calendar日期选择控件的样式 首先上图看下样式 原理 总览 ItemsControl内容的生成 实现 界面的实现 后台ViewModel的实现 首先上图,看下样式 原理 ...

  5. 8.算法竞赛中的常用JAVA API :Calendar日期类

    8.算法竞赛中的常用JAVA API :Calendar日期类 摘要 在蓝桥杯中有关于日期计算的问题,正好java中的Date类和Calendar类提供了对日期处理的一些方法.Date类大部分方法已经 ...

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

  7. 求大神帮解答calendar日期插件的问题

    小颖最近公司的项目里用了一款日期插件  calendar.js  但是在用的过程中遇到了难题,就是当日期只需要选择具体的月份就可以了,不需要再选具体日期时,小颖解决不了,只能让它默认显示出月份,但是月 ...

  8. Educational Codeforces Round 13 B. The Same Calendar 水题

    B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...

  9. Calendar 日期类介绍

    Calendar c = Calendar.getInstance();//创建实例 默认是当前时刻 c.get(Calendar.YEAR); c.get(Calendar.MONTH); c.ge ...

随机推荐

  1. java学习笔记--IO流

    第十二章大纲: I/O input/output 输入/输出 一.创建文件,借助File类来实现 file.createNewFile() : 创建文件 file.exists() : 判断文件是否存 ...

  2. Nginx反向代理到Tomcat服务器

    在实际生产中,Tomcat服务器一般不单独使用在项目中,对于静态资源的响应Nginx表现的比较好,另外由于nginx是专门用于反向代理的服务器,所以很容易实现将java的请求转发到后端交给tomcat ...

  3. metro压缩和解压文件

    在1.zip中增加一张新图片StorageFile jpg = await KnownFolders.PicturesLibrary.GetFileAsync("1.jpg"); ...

  4. ABAP 单位转换函数

    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'         EXPORTING           input                = wa_all-btg ...

  5. Js 旋转木马 轮播

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 检索COM 类工厂中 CLSID 为 {} 的组件时失败

  7. 经典排序算法 - 冒泡排序Bubble sort

    原理是临近的数字两两进行比较,按照从小到大或者从大到小的顺序进行交换, 这样一趟过去后,最大或最小的数字被交换到了最后一位, 然后再从头开始进行两两比较交换,直到倒数第二位时结束,其余类似看例子 例子 ...

  8. 【QT】C++ GUI Qt4 学习笔记3

    菜单界面的实现. 看书上第三章,好长,好多代码.我敲了半天,想看看效果,结果却显示不出来.仔细一看,发现spreadsheet的实现在第四章.郁闷.... 又到官网上下代码,结果居然不能运行.难道是因 ...

  9. 如何用Jquery判断在键盘上敲的哪个按键

    有时候我们需要判断我们在键盘上敲了哪个键,这个需要查询下键盘上的键对应的值是多少,比如Enter键是13. 下面是Jquery代码,别忘了引用Jquery包哈. <script type=&qu ...

  10. [Android Pro] ActionBarDrawerToggle 使用小结

    reference to  : http://blog.csdn.net/chencehnggq/article/details/21492417 activity.java mToolbar = ( ...