标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23160 Accepted Submission(s): 7404
1 #include<math.h> 2 #include<stdio.h> 3 #include<string.h> 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 #define N 155 8 9 int y,m,d,day_cnt,f1; 10 11 int judge(int year) 12 { 13 if( (year%4==0)&&(year%100!=0) || year%400==0 )return 1; 14 else return 0; 15 } 16 17 int main() 18 { 19 int t;cin>>t; 20 while(t--) 21 { 22 day_cnt=f1=0; 23 24 scanf("%d-%d-%d",&y,&m,&d); 25 if(judge(y)&&m==2&&d==29) 26 { 27 cout<<-1<<endl; 28 continue; 29 } 30 if(judge(y)&&m>=3){f1=-1;} 31 if(judge(y+18)&&m<3){f1=0;} 32 if(judge(y+18)&&m>=3){f1=1;} 33 for(int i=0;i<18;i++) 34 { 35 int yy=y+i; 36 if(judge(yy))day_cnt+=366; 37 else day_cnt+=365; 38 } 39 cout<<day_cnt+f1<<endl; 40 } 41 return 0; 42 43 } 44 45 /* 46 13 47 2004-1-22 48 2004-2-28 49 2004-2-29 50 2004-4-20 51 2003-2-20 52 2003-2-28 53 2003-3-20 54 2002-2-20 55 2002-2-28 56 2002-3-20 57 2001-2-20 58 2001-2-28 59 2001-3-20 60 */
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4671721.html