点击打开链接

E: Ever17

Time Limit: 1000 MS Memory Limit: 1048576 KB
Total Submit: 196 Accepted: 39 Page View: 573
Submit Status Clarify

Description

As is known to all, we have two formats to denote a specific date: MM/DD/YY or YY/MM/DD. We supposed the years discussed below are years in 20YY.

Now you are given a string representing the date. If there is only one possible date it can fit in with format of "MM/DD/YY" or "YY/MM/DD", output the date in the format of "month date, year" (as can be seen in the second sample). Otherwise, output the days between the two different dates it might be.

Input

The first line contains an integer Trepresenting the number of test cases.
In each test case, a string ”AA/BB/CC” is given in one line.
It is guaranteed that there is at least one legal date it can fit in with
format of ”MM/DD/YY” or ”YY/MM/DD”.1≤T≤5

Output

For each test case, if there are two different possible dates, output an integer in one line representing the days between the two possible dates. In the other case, output the exact date in one line.
  • Sample Input
  • Raw
3
02/07/19
19/02/07
07/02/19

  • Sample Output
  • Raw
6047
February 7, 2019
4516

Hint

In the first sample, the date might be July 19th, 2002 or February 7th, 2019. The number of days between the two dates are 6047 days.As for the second sample, the only possible date is February 7th, 2019.There are 12 months in a year and they are January, February, March, April, May, June, July, August, September, October, November and December.Also, please note that there are 29 days in February in a leap year while 28 days in nonleap year.

题意:

给一个合法的日期,可能是MM/DD/YY or YY/MM/DD,如果是其中的一种,则输出"month date, year",

否则,输出两个日期的差值,若差值为0,输出个日期

Otherwise, output the days between the two different dates it might be.

#include<bits/stdc++.h>
using namespace std;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int leap_day[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char month[13][10]={"","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" ,"December"};
bool leap(int y)
{if(y%4==0&&y%100!=0||y%400==0)return 1;return 0;
}
bool check(int y,int m,int d)
{if(y<0||y>99)   return 0;if(m<1||m>12)   return 0;if(d<1||d>31)   return 0;if(leap(y+2000)){if(d>leap_day[m])   return 0;}elseif(d>day[m])   return 0;return 1;
}
long long sum(int y,int m,int d)
{long long sum=0;for(int i=0;i<y;i++){if(leap(i+2000))sum+=366;elsesum+=365;}if(leap(y+2000)){for(int i=1;i<m;i++)sum+=leap_day[i];}else{for(int i=1;i<m;i++)sum+=day[i];}sum+=d;return sum;
}
void print(int y,int m,int d)
{printf("%s %d, %d\n",month[m],d,y+2000);
}
int main()
{int t;int a,b,c;scanf("%d",&t);while(t--){scanf("%d/%d/%d",&a,&b,&c);bool s1=check(c,a,b),s2=check(a,b,c);if(s1&&!s2) print(c,a,b);if(!s1&&s2) print(a,b,c);if(s1&&s2)//两种情况下都合法if(abs(sum(c,a,b)-sum(a,b,c)))//差值不为0printf("%lld\n",abs(sum(c,a,b)-sum(a,b,c)));else//输出一个日期//print(a,b,c);print(c,a,b);}return 0;
}

第十届四川省大学生程序设计竞赛相关推荐

  1. 河南省第十届ACM大学生程序设计竞赛总结

    省赛总结 被大牛虐的好惨,同时大概也找到了自己的位置,发现自己的不足,知耻而后勇,继续加油!!! 回顾这两天的经历: 第一天到达学校大概就十二点多,报完到直接去吃饭,吃过饭就随大部队一块去宾馆了,刚放 ...

  2. 四川高中计算机大赛官网,2018年(第十届)四川省大学生程序设计竞赛

    2018年(第十届) 四川省大学生程序设计竞赛 2018年6月1-3日,由四川省教育厅主办,西南科技大学承办的第十届四川省大学生程序设计竞赛在西南科技大学举行.本次参赛队伍以四川省内高校队伍为主,同时 ...

  3. 第十五届吉林省大学生程序设计竞赛

    最近刚打完吉林省程序设计竞赛,自己比较菜,成绩不是很好,拖累了两位队友,其中一位队友保研,并在比赛前一天拿到了百度的实习offer.另一位是备战考研. 比赛只过了A,B,E,L,M,最终41名 A题: ...

  4. 黑龙江计算机比赛,第十二届东北地区大学生程序设计竞赛和第十三届黑龙江省大学生程序设计竞赛在我校成功举行...

    2018年5月18日至20日,第十三届黑龙江省大学生程序设计竞赛和第十二届东北地区大学生程序设计竞赛在我校隆重举行.副校长刘胜辉.教务处长宋清昆分别代表组委会致欢迎辞,并宣布比赛开幕.黑龙江省计算机学 ...

  5. 2019河南省第十二届ACM大学生程序设计竞赛参赛感

    盼望着,盼望着,acm省赛终于来了.2019年5月6日,一大早我们三个队就从郑州出发前往驻马店市--黄淮学院,一首<写给黄淮>火起来的大学.第一次听说黄淮学院还是高三时候韩老师天天对我们的 ...

  6. 挑战程序设计竞赛_我系首次参加第六届中国大学生程序设计竞赛网络预选赛

    点击上方蓝字关注  「龙外信息工程系」 讲述有温度的故事    传递有态度的思想 2020年9月20日12时至17时,第六届中国大学生程序设计竞赛网络赛预选赛在杭州电子科技大学OJ成功举办,黑龙江外国 ...

  7. 第45届国际大学生程序设计竞赛(ICPC)银川站太原理工大学收获4枚奖牌

    第45届国际大学生程序设计竞赛(ICPC)银川站,由宁夏理工学院承办,于2021年5月15-16日在宁夏的石嘴山市进行. 太原理工大学在比赛中获得2银2铜共4枚奖牌的好成绩. 参加本次比赛的四个队,涵 ...

  8. 华农c语言程序设计教程陈湘骥,华农数信学子在第44届国际大学生程序设计竞赛勇夺金牌...

    数信学子在第44届国际大学生程序设计竞赛勇夺金牌 中国区决赛 上海站 南京站 哈尔滨站 近日,第44届国际大学程序设计竞赛(中国区决赛)在西北工业大学落下帷幕.我校数学与信息学院.软件学院的张宏海.何 ...

  9. 2020 年第一届辽宁省大学生程序设计竞赛

    2020 年第一届辽宁省大学生程序设计竞赛 A-组队分配 分析 代码 B-两点距离 分析 代码 C-轮到谁了? 分析 代码 F-最长回文串 分析 代码 G-管管的幸运数字 分析 代码 I-鸽子的整数运 ...

最新文章

  1. java dump分析工具_java性能分析与常用工具
  2. 【bzoj 2435】[Noi2011]道路修建(dfs)
  3. 基于JAVA+SpringMVC+Mybatis+MYSQL的鲜花销售系统
  4. 透明加密系统设计及实现-绪论
  5. GridView中的超级链接
  6. 2.中小型企业通用自动化运维架构 -- Ansible 安装
  7. 1.1.3 Friday the Thirteenth 黑色星期五
  8. java clear new_Java基础之Map的clear和new的区别
  9. 仿淘宝收货地址,本地数据库
  10. 基于最新导则下的生态环境影响评价技术方法及图件制作与案例实践
  11. win11快捷键常用表 最全面的win11快捷键使用指南
  12. 国标GB28181协议视频平台EasyGBS国标级联到上级宇视平台,不断切换在线和离线状态是什么原因?
  13. 四大开源3d游戏引擎探究(前言上)
  14. 初学js---动态生成表格
  15. 【战术性mark】JS 复制内容到剪贴板
  16. 牛X,网易开源了这个项目后,结果被山寨出了无数个网易云音乐APP,网友炸锅了!...
  17. HTML页面背景音乐自动循环播放
  18. linux之进程观察命令:ps和top
  19. 用Css3实现旋转的立方体
  20. SY6982E芯片了解

热门文章

  1. vnpy官网说明文档网址
  2. xlrd对excel单列处理
  3. 解方程 2014NOIP提高组 (数学)
  4. JavaScript系列文章:谈谈let和const
  5. 得到按钮所在DIV的ID
  6. thread php,php中关于线程thread的使用
  7. python解释器可以使用什么命令_python解释器用什么写的
  8. 剑三服务器文件在哪里,剑三服务器同步设置在哪
  9. centos7 怎么封装自己的镜像_「10」-CentOS7.5(1804)
  10. mysql数据对比同步_跨数据库mysql语句同步数据和对比运算