HDU 1201-18 Birthday

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.