首先有这样一个显然的事实,那就是每个月的第一天可以是星期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. SELinux的关闭与开启

    SELinux是美国国家安全局对于强制访问控制的实现,是NSA在Linux社区的帮助下开发的一种访问控制体系,所以SELinux可以看做是安全强化的Linux子系统,和防火墙有相似点,作用之一是保证计 ...

  2. ePass.CreateFile

    javascript和vbscript中没有结构体Struct,ePass的ActiveX对象中把各个参数都展开了,官方文档只给出了对应的代码,没有给出相应的数字,示例代码中却都是数字,其VC代码中有 ...

  3. [转]Android 学习资料分享(2015 版)

    转 Android 学习资料分享(2015 版) 原文地址:http://www.jianshu.com/p/874ff12a4c01 目录[-] 我是如何自学Android,资料分享(2015 版) ...

  4. C++库(TinyXML)

    C++库(TinyXML) 什么是XML? "当 XML(扩展标记语言)于 1998 年 2 月被引入软件工业界时,它给整个行业带来了一场风暴.有史以来第一次,这个世界拥有了一种用来结构化文 ...

  5. 【linux】sudo su切换到root权限

    在用户有sudo权限但不知道root密码时可用 sudo su切换到root用户

  6. 页面上有两个元素id相同,js中如何取值

    页面上有两个table,id都是”cont2",现要在js中取到这两个table,改变样式. js实现: var tab2=document.all.cont2(1);var  tab=do ...

  7. 【jquery】字符ascii码转换函数

    js 字符ascii码转换函数 字符转ascii码:用charCodeAt();ascii码砖字符:用fromCharCode(); 看一个小例子 <script> str="A ...

  8. 'XCTest/XCTest.h' file not found

    直接写解决方法吧:在报错的 Target 中的 Building Settings 中 Framework Search Paths 里面添加 $(PLATFORM_DIR)/Developer/Li ...

  9. 解决win10装不了wifi驱动

    右击,选择更新程序驱动软件 ok  好了

  10. String[] a = new String[]{"1","2"},我如果想增加一个"3"到a中,如何增加?

    在java中数组是定长的,当你声明了数组的大小后数组的长度就不能改变在你的程序中,数组的初始化大小为2,a[0]="1";a[1]="2",所以无法产生元素a[ ...