#include<stdio.h>
int daysOfMonth(int year, int month)
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8
|| month == 10 || month == 12)
return 31;
else if (month == 2)
return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0) ? 29 : 28;
else
return 30;
}
int main()
{
int n, x, y;
scanf("%d", &n);
while (n--)
{
scanf("%d %d", &x, &y);
int total = 0, year, month, day, dayInMonth;
for (year = x; year <= y; year++)
{
int two = year % 100, three = year % 1000;
for (month = 1; month <= 12; month++)
{
dayInMonth = daysOfMonth(year, month);
for (day = 1; day <= dayInMonth; day++)
{
if ((day * day == two || day * day == three)
&& (month * month == two || month * month == three))
total++;
}
}
}
printf("%d\n", total);
}
return 0;
}
ZOJ-3174
最新推荐文章于 2018-08-23 10:10:00 发布