#include <iostream>
#include <cstdio>
using namespace std;
int ar[12]={31,28,31,30,31,30,31,31,30,31,30,31};
bool isleapyear(int year)
{
if(year%4==0&&year%100!=0)return true;
else if(year%400==0) return true;
return false;
}
int calmonthday(int year,int month)
{
int day = 0;
day = ar[month-1];
if(isleapyear(year)&&month==2) day += 1;
return day;
}
int caldaydatebackfirstmonth(int year,int month,int day)
{
int sum = 0;
for(int i=1;i<month;i++)
sum += calmonthday(year,i);
sum += day;
return sum;
}
int calbackmonth(int year,int month,int day)
{
int sum = caldaydatebackfirstmonth(year,month,day);
if(isleapyear(year)) return 366-sum;
else return 365-sum;
}
int howdays(int year)
{
if(isleapyear(year)) return 366;
return 365;
}
int eigthyear(int year,int month,int day)
{
int y = year+18;
int sum = 0;
sum = calbackmonth(year,month,day);
for(int i=year+1;i<y;i++)
sum += howdays(i);
sum += caldaydatebackfirstmonth(y,month,day);
return sum;
}
bool havebirthday(int year,int month,int day)
{
int y = year+18;
if(isleapyear(year) && month==2&&day == 29)
{
if(isleapyear(y)) return true;
return false;
}
return true;
}
int main()
{
int test;
scanf("%d",&test);
while(test--)
{
int year,month,day;
scanf("%d-%d-%d",&year,&month,&day);
if(!havebirthday(year,month,day))
puts("-1");
else
printf("%d\n",eigthyear(year,month,day));
}
return 0;
}
hdu 1201
最新推荐文章于 2020-03-02 10:40:50 发布