-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5723.d
93 lines (74 loc) · 1.4 KB
/
5723.d
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import std.stdio;
//import std.algorithm;
//import std.math;
//import std.conv;
//import std.numeric;
//import std.range;
//import std.array;
//import std.bigint;
//import std.string;
bool leap(int y){
if(y%400 == 0){
return true;
}
if(y%100 == 0){
return false;
}
if(y%4 == 0){
return true;
}
return false;
}
const int[12] dim = [
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
];
int unit(int y, int m, int d){
int ans = 0;
foreach(i; 1900..y){
ans += 365+leap(i);
}
foreach(i; 1..m){
ans += dim[i-1];
if(i==2 && leap(y)){ans++;}
}
return ans+d;
}
void sol(int n){
int d, m, y, c;
int D, M, Y, C;
int u, U, diff, days, cons;
bool know;
n--;
scanf("%d %d %d %d", &d, &m, &y, &c);
u = unit(y, m, d);
while(n--){
scanf("%d %d %d %d", &D, &M, &Y, &C);
U = unit(Y, M, D);
diff = U-u;
if(diff == 1){
days++;
cons += C-c;
know = true;
}
else if(C == c){
days += U-u+1-know;
know = true;
}
else{
know = false;
}
d = D; m = M; y = Y; c = C; u = U;
}
printf("%d %d\n", days, cons);
}
void main(){
int n = 1;
while(n){
scanf("%d", &n);
if(n){
sol(n);
}
}
}