HDU 1201(18岁生日天数)
来源:互联网 发布:网络发展前景 编辑:程序博客网 时间:2024/05/17 04:34
#include <iostream>#include <cstdio>#include <algorithm>#include <string>#include <cstring> using namespace std;const int MAXN = 10000 + 10;int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};/*HDU 1201关键: T组测试数据, 每一组测试数据输入之前都要保证前面用到的数据没有保留*/bool isPlanted(int year){return !( (year%4==0 && year%100!=0) || (year%400)==0 );}int main(){int T;scanf("%d", &T);for(int i=0; i<T; i++){int year, month, day;year = month = day = 0;scanf("%d-%d-%d", &year,&month,&day);if( (month==2) && (day==29) && !isPlanted(year) ){cout << -1 << endl;continue;}else if( !isPlanted(year) ){months[2] = 29;}else{months[2] = 28;}/////////////////////////////////////int days=0, sum = 0;// days->生日离该年1月1日有几天, sum->18年后的生日离该年1月1日有几天 for( int m=1; m<month; m++){days += months[m];}days += day;for( int y=year; y<year+18; y++){if( isPlanted(y) ){sum += 365;}else{sum += 366;}}if( isPlanted(year+18) ){months[2] = 28;}else {months[2] = 29;}for( int m=1; m<month; m++){sum += months[m];}sum += day;cout << (sum-days) << endl;}return 0;}
0 0
- hdu 1201 18岁生日 天数模拟
- HDU 1201(18岁生日天数)
- 18岁生日天数问题
- HDOJ 1201 18岁生日(日期与天数计算)
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- hdu - 1201 - 18岁生日
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- hdu-1201-18岁生日
- HDU: 1201-18岁生日
- hdu 1201 18岁生日
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- hdu-1201-18岁生日
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- Spring 笔记
- 实现统计java程序代码的小工具
- 员工信息管理表
- HDU 1076(第n个闰年)
- hdu5029 Relief grain 点权树链剖分,线段树
- HDU 1201(18岁生日天数)
- 在Eclipse或者ADT中使用ButterKnifeZelezny,Android组件初始化从此变得简单易懂!!!!,androideclipseadt 一、起因 想必使用And
- 【网络】(二)流协议粘包问题
- JVM监测工具和实践
- HDU 3368(翻转棋)
- POJ - 1182 食物链(种类并查集经典题)
- 仿QQ消息Listview侧滑置顶、删除
- HDU 3363(分冰糖葫芦)
- 笔试面试题总结(一)--- 软件开发