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 ...
随机推荐
- C++实现VPN工具之常用API函数
RAS是Remote Access Service的缩写,意为:远程访问服务,主要用来配置企业的远程用户对企业内部网络访问,包括拨号访问和vpn方式.微软的所有Windows平台中都有RAS客户机,它 ...
- FastReport中文网
FastReport中文网 http://www.fastreportcn.com/Article/2.html
- Ubuntu ( Linux) Eclipse 乱码问题
刚装完Ubuntu,导入Java和Android项目时,发现字符乱码,究其原因,是由于Windows下使用的是GBK编码,而Ubuntu使用的是UTF-8编码.网上查找了相关资料,主要解决方案有两种. ...
- struts2环境配置
struts2环境配置 struts2框架,大多数框架都在使用.由于工作需要,开始做Java项目.先学个struts2. 一.下载struts2 有好多版本,我下载的是struts-2.2.1.1. ...
- 【leetcode】Shortest Palindrome(hard)★
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...
- 【网络】ssl与ssh
ssh(安全外壳协议):百度百科 ssl(安全套接字):http://kb.cnblogs.com/page/162080/ https应用了ssl协议 ssh与ssl的区别:http://blog. ...
- (2016弱校联盟十一专场10.2) A.Nearest Neighbor Search
题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[], ...
- ios 中清除webView的缓存
在UIWebView下,可以使用 [[NSURLCache sharedURLCache] removeAllCachedResponses];//清除缓存 来实现清除缓存,但当替换使用WKWebVi ...
- rsync.conf详解
1.在服务端编辑配置文件 [root@game_intf ~]# more /etc/rsyncd.conf port=8730 log file=/var/log/rsync.log pid fil ...
- GridView中使用分页控件
前台:导入<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix= ...