[HDU] [2033] Everyone Loves A+B

Problem Description

Loading...

Problem Analysis

I thought this one was pretty interesting at the time
Which is to say…
Come on…
Why is it A+B again
How many A+B problems can there possibly be -.-
This problem is just about simulating carries
Back then I didn’t know structs yet
If I wrote it now, I’d probably just define a struct and do it that way

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
int main() {
    int i,j,AH,AM,AS,BH,BM,BS,H,M,S;
    scanf("%d",&j);
    for(i=0; i<j; i++) {
        H=M=S=0;
        scanf("%d %d %d %d %d %d",&AH,&AM,&AS,&BH,&BM,&BS);
        S=AS+BS;
        if(S>=60) {
            S=S-60;
            M=M+1;
        }
        M=M+AM+BM;
        if(M>=60) {
            M=M-60;
            H=H+1;
        }
        H=H+AH+BH;
        printf("%d %d %d\n",H,M,S);
    }
    return 0;
}

Loading...