18-year-old birthday
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 INPUT1 1988-03-07
Sample Output6574 Code:
1#include <cstdio>2 using namespacestd;3 4 BOOLJudgeintYear )5 {6 if((year%4==0&&year% -!=0)|| year% -==0)7 return true;8 return false;9 }Ten One intMain () A { - intCount,year,month,day; - intt,i; thescanf"%d",&t); - while(t--) - { -Count= -*365; +scanf"%d-%d-%d",&year,&month,&Day ); - if(month==2&&day== in) + { Aprintf"-1\n"); at Continue; - } - for(i=year+1; i<=year+ -; i++) - { - BOOLflag=judge (i); - if(flag) incount++; - } to if(month<=2) + if(judge (year)) -count++; the if(month>2) * if(Judge (year+ -)) $count++;Panax Notoginsengprintf"%d\n", count); - } the return 0; +}
HDU 1201-18 Birthday