HDU 1201
18岁生日
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18353 Accepted Submission(s): 5804
1
1988-03-07
6574
#include<stdio.h>
int leap(int Y)
{
if(Y%4==0&&Y%100!=0||Y%400==0) return 1;
else return 0;
}
int main()
{
int i,T;
int Y,M,D;
int Date;
scanf("%d",&T);
while(T--)
{
Date=18*365;
scanf("%d-%d-%d",&Y,&M,&D);
if(!leap(Y+18)&&M==2&&D==29)
{
printf("-1\n");continue;
} if(leap(Y)&&(M<2||M==2)&&D<=28) Date++;//此处有逻辑问题,不加括号会出现错误
//if(leap(Y)&&M==2&&D==29&&leap(Y+18)) Date++;
//if(M>2&&leap(Y+18)) Date++;
if(leap(Y+18)&&M>2||M==2&&D==29) Date++;
for(i=Y+1;i<=Y+17;i++)
{
if(leap(i)) Date++;
}
printf("%d\n",Date);
}
return 0;
}
HDU 1201的更多相关文章
- hdu 1201 18岁生日
#include <stdio.h> int r(int y) { return (y%4==0&&y%100!=0)||(y%400==0); } int f(int y ...
- hdu 1201:18岁生日(水题,闰年)
18岁生日 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- HDU 1201 Fibonacci Again
Fibonacci Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1201 18岁生日 【日期】
18岁生日 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- POJ 1201 && HDU 1384 Intervals(差动制动系统)
职务地址:POJ 1201 HDU 1384 依据题目意思.能够列出不等式例如以下: Sj-Si>=c; Si-S(i-1)>=0; S(i-1)-Si>=-1; 然后用最短路s ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
随机推荐
- 10881 - Piotr's Ants
Problem D Piotr's Ants Time Limit: 2 seconds "One thing is for certain: there is no stopping th ...
- opencv做的美女找茬程序~
// CMP.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <cv.h> #include <high ...
- win8vs2012创建自带sqlServer数据库出错
以前写程序的时候,一直使用的sqlite,今天心血来潮,想用vs2012连接自身带的数据库,结果就出现错误: 啊,看到这个错误,咱赶紧上网搜搜,啊,有关的日志也是比较少的,经过一番苦战之后,终于好了, ...
- 如何设置lmt的空间警告阀值
Example—设置Locally Managed Tablespace的空间警告阀值 The following example sets the free-space-remaining thre ...
- IE_haslayout_与众多bug的纠缠
haslayout是什么: haslayout是IE的特有属性,就是has(有)layout(布局样式)! 在IE浏览器中,有的元素是默认“has” layout(有布局样式的),而有的元素是没有la ...
- information_schema模式表介绍 processlist
在mysql里,我们一般通过show (full)processlist查看当前连接情况,处理各种数据库问题.现在在information_schema模式下,5.5以后增加了processlist表 ...
- Android中获取IMEI码
Imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) .getDeviceId(); 1.加入权限 在manifest.xml ...
- JavaScript学习总结1
/***我是切割线 的開始***/ //利用prototype属性能够加入公有属性和方法 function myConstructor2(){ this.a='大灰狼'; }; //声明构造函数,能够 ...
- Dom生成Xml和解析Xml
xml这样的文件格式在非常多时候都是非常适合我们用来存取数据的,所以利用程序来生成xml文件和解析xml文件就显得比較重要了.在dom中是把每个元素都看做是一个节点Node的,全部页面上的属性.元素等 ...
- BPL vs. DLL
第一部分:有关包的介绍 一般我们编写编译一个DELPHI应用程序时,会产生一个EXE文件,也就是一个独立的WINDOWS应用程序.很重要的一点:区别于Visual Basic,DELPHI产生的是预先 ...