/
12439.cpp
54 lines (41 loc) · 1.21 KB
/
12439.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <string>
using namespace std;
#define pow2(i) (1<<i)
#define bit(i) (1<<i)
#define isOdd(i) (i&1)
#define isEven(i) (!(i&1))
#define sz(i) i.size()
#define REP(i, b, n) for (int i = b; i < n; i++)
#define REPI(i, b, n) for (int i = b; i <= n; i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
string months[] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
int month_to_int(const string& month) {
rep (i, 12) {
if (month == months[i])
return i+1;
}
return -1;
}
int main(void) {
int t, d1, m1, y1, d2, m2, y2, result;
char ignore;
string month;
cin >> t;
REPI (case_number, 1, t) {
cin >> month >> d1 >> ignore >> y1;
m1 = month_to_int(month);
cin >> month >> d2 >> ignore >> y2;
m2 = month_to_int(month);
if (m1 > 2)
y1++;
if (m2 < 2 || m2 == 2 && d2 < 29)
y2--;
result = y2 / 4 - (y1 - 1) / 4;
result -= y2 / 100 - (y1 - 1) / 100;
result += y2 / 400 - (y1 - 1) / 400;
cout << "Case " << case_number << ": " << result << endl;
}
return 0;
}