-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodechef - age calculator.cpp
72 lines (66 loc) · 1.44 KB
/
codechef - age calculator.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 10010;
int daysInMonth[sz];
int t, n, db, dc, mb, mc, yb, yc;
ll daysinayear;
ll ans;
int main()
{
//freopen("_in.txt", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
while(t--)
{
cin >> n;
daysinayear = 0;
for(int i=1; i<=n; i++)
{
cin >> daysInMonth[i];
daysinayear += daysInMonth[i];
}
cin >> yb >> mb >> db;
cin >> yc >> mc >> dc;
if(yb==yc)
{
if(mb==mc)
{
ans = dc - db + 1;
}
else
{
ans = daysInMonth[mb]-db+1;
for(int i=mb+1; i<mc; i++)
{
ans += daysInMonth[i];
}
ans += dc;
}
}
else
{
ans = daysInMonth[mb]-db+1;
for(int i=mb+1; i<=n; i++)
{
ans += daysInMonth[i];
}
ans += (daysinayear*(yc-yb-1));
for(int i=1; i<mc; i++)
{
ans+=daysInMonth[i];
}
ans += dc;
for(int i=yb; i<yc; i++)
{
if(i%4==0)
{
ans++;
}
}
}
cout << ans << "\n";
}
return 0;
}