杭电ACM 1201
#include <stdio.h>
int func(int year)
{
if ( year % 400 == 0 || (year % 4 == 0 &&year % 100 != 0 ) )
return 1;
return 0;
}
int main(int argc, char* argv[])
{
int y,m,d,index;
char c;
int sum;
scanf("%d",&index);
while (index--)
{
sum = 0 ;
scanf("%d%c%d%c%d%c",&y,&c,&m,&c,&d,&c);
if (m==2 && d ==29)
{
printf("-1\n");
continue;
}
for (int i = 1 ; i<= 18 ; ++i )
{
if ( func(y+i) )
sum += 366;
else
sum += 365;
}
if (func(y) && m <= 2)
{
sum++;
}
if (func(y+18) && m <= 2)
{
sum--;
}
printf("%d\n",sum);
}
return 0;
}