- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
54 lines (41 loc) · 1.15 KB
/
A.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>
boolisLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
intdaysInMonth(int year, int month) {
constint daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
return daysInMonth[month];
}
intmain() {
int year1, month1, day1, hour1, min1, sec1;
int year2, month2, day2, hour2, min2, sec2;
std::cin >> year1 >> month1 >> day1 >> hour1 >> min1 >> sec1;
std::cin >> year2 >> month2 >> day2 >> hour2 >> min2 >> sec2;
longlong fullDays = 0;
longlong remainingSeconds = 0;
while (year1 != year2 || month1 != month2 || day1 != day2) {
remainingSeconds += 24ll * 60 * 60;
day1++;
if (day1 > daysInMonth(year1, month1)) {
day1 = 1;
month1++;
if (month1 > 12) {
month1 = 1;
year1++;
}
}
if (day1 > daysInMonth(year1, month1)) {
day1 = 1;
month1++;
if (month1 > 12) {
month1 = 1;
year1++;
}
}
}
remainingSeconds += (hour2 - hour1) * 3600 + (min2 - min1) * 60 + (sec2 - sec1);
fullDays = remainingSeconds / (24 * 60 * 60);
remainingSeconds %= (24 * 60 * 60);
std::cout << fullDays << "" << remainingSeconds << std::endl;
return0;
}