首先有这样一个显然的事实,那就是每个月的第一天可以是星期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. linux内置的审计跟踪工具------last和lastb

    last是linux的一个内置工具,可以用来查看最后登录服务器的用户.它对于追踪非常有用. last命令显示的是来自/var/log/wtmp文件创建起,所有登录的用户.这个文件是一个二进制文件,不能 ...

  2. 8.nodejs权威指南--MongoDB

    1. MongoDB var mongo = require('mongodb'); var host = '127.0.0.1'; var port = mongo.Connecton.DEFAUL ...

  3. nyoj_31

    题目描述:五个数求最值. #include <iostream> #include <algorithm> using namespace std; int main(){ ] ...

  4. hdu 1556.Color the ball 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556 题目意思:有 n 个气球从左到右排成一排,编号依次为1,2,3,...,n.给出 n 对 a, ...

  5. JSTL的c:forEach标签(${status.index})

    <c:forEach>标签具有以下一些属性: var:迭代参数的名称.在迭代体中可以使用的变量的名称,用来表示每一个迭代变量.类型为String. items:要进行迭代的集合.对于它所支 ...

  6. 【数据结构】book3_3 表达式求值

    #include<iostream> #include <stdlib.h> using namespace std; typedef int Status; ; ; ; ; ...

  7. 【XLL API 函数】xlAbort

    C API 中有 15个 Excel 回调函数只能使用 Excel4.Excel4v.Excel12.Excel12v 函数调用(或间接的使用框架函数 Excel 或 Excel12f 调用).也就是 ...

  8. 警告:Assigning to 'id<Delegate>' from incompatible type 'ViewController *const_st

    原因: 你自己写了代理,设置了   delegate = self.但是self 没有遵守这个协议 只需要遵守这个协议就可以消除警告.

  9. php与xpath使用操作文本节点

    <?php $html="<p> 对于2014年,省统计局的统计分析显示,我省消费流通领域受诸多因素的影响,有机遇也有挑战.但值得注意的是,消费增长还存在不少制约因素,比如 ...

  10. ASP.net绑定文本框Enter事件到按钮 ASP.NET执行后台执行JS方法

    txtAccountBarcode.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if (( ...