ORIGIN

HDU-2033 Clock time A+B

ACM 2 mins353 words

Clock time A + B

There are already 10 A + B questions on HDOJ. I believe these questions were once everyone ’s favorite. I hope that this A + B today will bring good luck to everyone. I also hope that this question will evoke everyone’s concerns about ACM Love.

A and B in this topic are not simple integers, but two times. A and B are composed of 3 integers, which represent hours, minutes, and seconds. For example, if A is 34 45 56, it means that the time represented by A is 34 hours, 45 minutes, and 56 seconds.

Input

The input data consists of multiple lines. First is an integer N, which represents the number of test instances, and then N rows of data. Each line has 6 integers AH, AM, AS, BH, BM, BS, which represent the times A and B, respectively. The corresponding hour, minute, and second. The title guarantees that all data is legal.

Output

For each test instance, output A + B. Each output result is also composed of 3 hours, minutes, and seconds. At the same time, the rules of time must be met (that is, the range of minutes and seconds is 0 ~ 59). One line, and all parts can be represented by 32-bit integers.

Sample Input

1
2
3
2
1 2 3 4 5 6
34 45 56 12 23 34

Sample Output

1
2
5 7 9
47 9 30

Analysis

Just stimulate the rule of clock time addition.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<bits/stdc++.h>

using namespace std;

int main() {
int t;
cin >> t;
int a[3], b[3], c[3];
while(t --) {
for(int i = 0; i < 3; i ++) cin >> a[i];
for(int i = 0; i < 3; i ++) {
cin >> b[i];
c[i] = a[i] + b[i];
}
for(int i = 2; i >= 1; i --) {
c[i - 1] += c[i] / 60;
c[i] %= 60;
}
cout << c[0] << " " << c[1] << " " << c[2] << endl;
}
return 0;
}
TOP
COMMENT
  • ABOUT
  • |
o_oyao
  The Jigsaw puzzle is incomplete with even one missing piece. And I want to be the last piece to make the puzzle complete.
Like my post?
Default QR Code
made with ❤️ by o_oyao
©o_oyao 2019-2024

|