HDU-ACM2033

来源:互联网 发布:seo综合查询 编辑:程序博客网 时间:2024/06/06 09:44

人见人爱A+B

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36947    Accepted Submission(s): 24591


Problem Description
HDOJ上面已经有10来道A+B的题目了,相信这些题目曾经是大家的最爱,希望今天的这个A+B能给大家带来好运,也希望这个题目能唤起大家对ACM曾经的热爱。
这个题目的A和B不是简单的整数,而是两个时间,A和B 都是由3个整数组成,分别表示时分秒,比如,假设A为34 45 56,就表示A所表示的时间是34小时 45分钟 56秒。
 

Input
输入数据有多行组成,首先是一个整数N,表示测试实例的个数,然后是N行数据,每行有6个整数AH,AM,AS,BH,BM,BS,分别表示时间A和B所对应的时分秒。题目保证所有的数据合法。
 

Output
对于每个测试实例,输出A+B,每个输出结果也是由时分秒3部分组成,同时也要满足时间的规则(即:分和秒的取值范围在0~59),每个输出占一行,并且所有的部分都可以用32位整数表示。
 

Sample Input
21 2 3 4 5 634 45 56 12 23 34
 

Sample Output
5 7 947 9 30

import java.util.*;class Main{    public static void main(String args[]){        Scanner input=new Scanner(System.in);        int n=input.nextInt();        for (int i=0;i<n ;i++ )        {            int a[]=new int[3];            int b[]=new int[3];            int s[]=new int[3];            for (int j=0;j<3 ;j++ )            {                a[j]=input.nextInt();            }            for (int j=0;j<3 ;j++ )            {                b[j]=input.nextInt();            }            s[0]=a[0]+b[0];            s[1]=a[1]+b[1];            s[2]=a[2]+b[2];            if (s[2]>59)            {                s[1]++;                s[2]-=60;            }            if (s[1]>59)            {                s[0]++;                s[1]-=60;            }            for (int j=0;j<2 ;j++ )            {                System.out.print(s[j]+" ");            }            System.out.println(s[2]);        }    }}


0 0