zoukankan      html  css  js  c++  java
  • 杭电ACM2033人见人爱A+B

    人见人爱A+B

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


    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
    2
    1 2 3
    4 5 6
     
    34 45 56
    12 23 34
     
    Sample Output
    5 7 9
    47 9 30
     
     1 import java.util.Scanner;
     2 public class Main{
     3     public static void main(String[] args) {
     4         Scanner scan = new Scanner(System.in);
     5         int AH,AM,AS;
     6         int BH,BM,BS;
     7         int CH,CM,CS;
     8         int n = scan.nextInt();
     9         for(int i=0;i<n;i++){
    10             AH = scan.nextInt();
    11             AM = scan.nextInt();
    12             AS = scan.nextInt();
    13             BH = scan.nextInt();
    14             BM = scan.nextInt();
    15             BS = scan.nextInt();
    16             int temps = 0;
    17             temps = AS+BS;
    18             
    19             CS = (temps)%60;
    20             int tempm = 0;
    21             tempm = (AM+BM)+(temps)/60;
    22             CM = (tempm)%60;
    23             
    24             CH = (AH+BH)+tempm/60;
    25             System.out.println(CH+" "+CM+" "+CS);
    26         }
    27     }
    28 }
  • 相关阅读:
    js中有趣的闭包(closure)
    js常见函数汇总
    js时间处理
    一些JavaScript的技巧、秘诀和最佳实践
    js创建对象的6种方式
    js数组常用方法汇总
    左右点击分页方法
    dedecms 添加自定义图字段,调用时出错
    js判断PC端与移动端跳转
    php验证码
  • 原文地址:https://www.cnblogs.com/bchxsx322/p/2446753.html
Copyright © 2011-2022 走看看