Hduoj 18-year-old birthday topic 1201

Source: Internet
Author: User



The subject is a careful question to consider various situations

#include <stdio.h>
int pan (int n)
{
if (n%400==0| | (n%4==0&&n%100!=0))
return 1;
else return 0;
}
int main ()
{
int t;
scanf ("%d", &t);
while (t--)
{
int day,mon,year,sum=0,i;
scanf ("%d-%d-%d", &year,&mon,&day);
if (Pan (year) ==1&&day==29&&pan (year+18) ==0)
{
printf (" -1\n");
Continue
}
sum=365*18;//by common year first.
for (int i=year+1;i<year+18;i++)//Calculate how many years
{
if (pan (i) ==1) sum+=1;
}
if (Pan (year) ==1&& (mon==1| | (mon==2&&day<29))) sum+=1;//birthday that year is run year and in January or before 29
if (Pan (year+18) ==1&& (mon>=3)) SUM+=1;//18 year's birthday is after March and is a year of embellish
printf ("%d\n", sum);
}
return 0;
}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hduoj 18-year-old birthday topic 1201

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.