14
2020/08/22 23:48:00 2020/08/22 23:48:59
2020/08/22 23:48:59 2020/08/22 23:48:00
2020/08/22 23:22:
<463 bytes omitted>
用户输出
59
59
1537
82527
1032927
21164127
17902896185
-1
-1
-1
-1
-1
-1
315537897599
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#81209 | #112. czq的时间间隔 | Accepted | 100 | 11 ms | 384 K | C++ 11 / 1.4 K | Corycle | 2022-08-26 13:47:25 |
/*====Corycle====*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e4 + 5;
int read() {
int s = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
s = s * 10 + c - '0';
c = getchar();
}
return s * f;
}
int sum[N];
int Day(int x, int y) {
if (y == 2) {
if (x % 4)
return 28;
if (!(x % 100) && x % 400)
return 28;
return 29;
}
if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
return 31;
return 30;
}
int main() {
// freopen("_.in","r",stdin);
// freopen("_.out","w",stdout);
for (int i = 1; i <= 9999; i++) sum[i] = sum[i - 1] + (Day(i - 1, 2) == 28 ? 365 : 366); // before year i
int T = read();
while (T--) {
int Y1 = read(), M1 = read(), D1 = read(), h1 = read(), m1 = read(), s1 = read();
int Y2 = read(), M2 = read(), D2 = read(), h2 = read(), m2 = read(), s2 = read();
if (Y1 == 0 || Y2 == 0 || M1 > 12 || M2 > 12 || D1 > Day(Y1, M1) || D2 > Day(Y2, M2) || h1 >= 24 ||
h2 >= 24 || m1 >= 60 || m2 >= 60 || s1 >= 60 || s2 >= 60) {
puts("-1");
continue;
}
if ((Y1 > Y2) || (Y1 == Y2 && M1 > M2) || (Y1 == Y2 && M1 == M2 && D1 > D2) ||
(Y1 == Y2 && M1 == M2 && D1 == D2 && h1 > h2) ||
(Y1 == Y2 && M1 == M2 && D1 == D2 && h1 == h2 && m1 > m2) ||
(Y1 == Y2 && M1 == M2 && D1 == D2 && h1 == h2 && m1 == m2 && s1 > s2)) {
swap(Y1, Y2);
swap(M1, M2);
swap(D1, D2);
swap(h1, h2);
swap(m1, m2);
swap(s1, s2);
}
ll dltD = 0, dltS = 0;
for (int i = 1; i < M1; i++) dltD -= Day(Y1, i);
dltD -= D1 - 1;
for (int i = 1; i < M2; i++) dltD += Day(Y2, i);
dltD += D2 - 1;
dltD += sum[Y2] - sum[Y1];
dltS = 3600 * (h2 - h1) + 60 * (m2 - m1) + (s2 - s1);
printf("%lld\n", 86400 * dltD + dltS);
}
return 0;
}
14
2020/08/22 23:48:00 2020/08/22 23:48:59
2020/08/22 23:48:59 2020/08/22 23:48:00
2020/08/22 23:22:
<463 bytes omitted>
用户输出
59
59
1537
82527
1032927
21164127
17902896185
-1
-1
-1
-1
-1
-1
315537897599
系统信息
Exited with return code 0
10000
5348/13/26 20:09:36 5809/10/09 11:17:33
8951/13/09 02:54:35 1245/10/20 19:37:36
7524/01/04 20:
<399906 bytes omitted>
-1
-1
52181193949
167527773820
11151421677
176367406636
34137847390
71087537213
156479412870
<102130 bytes omitted>
用户输出
-1
-1
52181193949
167527773820
11151421677
176367406636
34137847390
71087537213
156479412870
-1
-1
81508312928
163816674890
-1
6
<92102 bytes omitted>
系统信息
Exited with return code 0