#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
bool is_leap(int y) {
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
return true;
return false;
}
int get_month_days(int y, int m) {
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
return 31;
if (m == 4 || m == 6 || m == 9 || m == 11)
return 30;
if (is_leap(y))
return 29;
else
return 28;
}
int day_of_year(int y, int m, int d) {
for (int i = 1; i < m; i++)
d += get_month_days(y, i);
return d;
}
int main(int argc, char* argv[]) {
int y, m, d;
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%d/%d/%d", &y, &m, &d);
printf("%d\n", day_of_year(y, m, d));
}
return 0;
}
|