人见人爱A+B
2016-05-11 20:59
357 查看
人见人爱A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37106 Accepted Submission(s): 24687
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
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; int main() { int t; cin>>t; while(t--) { int AH,AM,AS,BH,BM,BS; while(scanf("%d%d%d%d%d%d",&AH,&AM,&AS,&BH,&BM,&BS)!=EOF) { int h,m,s; if(BS+AS>59) { s=BS+AS-60; AM++; } else { s=BS+AS; } if(AM+BM>59) { m=AM+BM-60; AH++; } else { m=AM+BM; } h=AH+BH; cout<<h<<" "<<m<<" "<<s<<endl; } } return 0; }
相关文章推荐
- Stanford 机器学习 Anomaly Detection
- 积木算法
- 258. Add Digits [easy] (Python)
- mysql数据访问
- 符号三角形
- JAVA004--3种循环对比,for;while;do{}while
- Leetcode Everyday: 344. Reverse String
- java 中static final用法
- 神经语言学中的卷积神经网络
- 第五次作业
- There was an internal API error.
- C++11 之 override 关键字
- LintCode:线段树的查询
- APM 姿态抗风(干扰 突变) 优化处理
- 图解TCP-IP协议
- C++ Primer 中文版 5th Edition 练习15.8和练习15.9的解答
- Linux命令技巧
- lower power的physical library
- Deep Learning(深度学习)资料汇总
- 动态规划——problem B