18-year-old birthday
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 23160 Accepted Submission (s): 7404
Problem Descriptiongardon's 18 birthday is coming, he is certainly very happy, but he suddenly thought of a question, is everyone from birth, to reach the 18 birthday when the number of days are the same? It doesn't seem to be all that, so he wants to ask you to calculate the total number of days he and his friends have passed since they were born to their 18 birthday.
Input is a number T, and the following T line has a date on each line, and the format is YYYY-MM-DD. As my birthday is in 1988-03-07.
Outputt lines, one number per line, indicating the number of days that the person has passed from birth to the age of 18. If this person does not have a 18 birthday, then output-1.
Sample input11988-03-07
Sample Output6574
Authorgardon
Source Gardon-dygg Contest 2
recommendjgshining | We have carefully selected several similar problems for you:1205 1106 1215 1228 1234 The problem is to pay attention to some details, one is the beginning of the first year is not leap years, is the words in the leap 2.29 Front or back, one is 18 years old is not a leap year, is the words in 2.29 front or back, there is a leap year of 2.29 of the special sentence will be gone. Hangzhou Electric Discussion Group A person's data is very good, in the final comment of the code.
1#include <math.h>2#include <stdio.h>3#include <string.h>4#include <iostream>5#include <algorithm>6 using namespacestd;7 #defineN 1558 9 inty,m,d,day_cnt,f1;Ten One intJudgeintYear ) A { - if((year%4==0) && (year% -!=0) || year% -==0)return 1; - Else return 0; the } - - intMain () - { + intT;cin>>T; - while(t--) + { Aday_cnt=f1=0; at -scanf"%d-%d-%d",&y,&m,&d); - if(Judge (Y) &&m==2&&d== in) - { -cout<<-1<<Endl; - Continue; in } - if(Judge (Y) &&m>=3) {f1=-1;} to if(Judge (y+ -) &&m<3) {f1=0;} + if(Judge (y+ -) &&m>=3) {f1=1;} - for(intI=0;i< -; i++) the { * intyy=y+i; $ if(Judge (yy)) day_cnt+=366;Panax Notoginseng Elseday_cnt+=365; - } thecout<<day_cnt+f1<<Endl; + } A return 0; the + } - $ /* $ - - 2004-1-22 - 2004-2-28 the 2004-2-29 - 2004-4-20Wuyi 2003-2-20 the 2003-2-28 - 2003-3-20 Wu 2002-2-20 - 2002-2-28 About 2002-3-20 $ 2001-2-20 - 2001-2-28 - 2001-3-20 - */
HDU 1201-18 Birthday