【早起一水】HDU——1201 18岁生日
来源:互联网 发布:做微信小视频的软件 编辑:程序博客网 时间:2024/05/16 17:38
【早起一水】HDU——1201 18岁生日
描述:
Gardon的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都是这样,所以他想请你帮忙计算一下他和他的几个朋友从出生到达18岁生日所经过的总天数,让他好来比较一下。
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1201
代码:
#include<iostream>#include<cstdio>int arr[15]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int isRunNian(int y){ if( y%400==0 || (y %4==0 && y %100!=0)) return 1; else return 0;}int main(){ int t; scanf("%d", &t); while( t-- ){ int y, m, d, sum=0; scanf("%d-%d-%d", &y, &m, &d); if( m==2 && d==29 ){ printf("-1\n"); continue; } //根据m是否大于二月来确定计时的时段 if( m>2 ) y++; for(int i=y; i<=y+17; i++){ if( isRunNian( i )){ sum+=366; }else{ sum+=365; } } printf("%d\n", sum); } return 0;}
- 【早起一水】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岁生日
- HDU 1201 18岁生日
- HDU 1201 18岁生日
- hdu-1201-18岁生日
- HDU 1201 18岁生日
- 黑客必备工具分类大全(精)
- Xcode调试相关
- 提问的艺术(中文版)
- Objective-C的setter和getter
- hook iat改变Messagebox
- 【早起一水】HDU——1201 18岁生日
- Useful website
- 十年积累)div+css 完全兼容ie6 ie7 IE8 IE9 和firefox方法
- 八皇后问题
- Linux - Find string in files.
- 深入浅出MFC学习笔记(第8章:Document----View深入探讨)
- discuz如何把登录框移到最顶的菜单栏,只显示一个登录和注册按钮?
- Struts2分页例子
- redis的brpop简单使用