设为首页 加入收藏

TOP

HDOJ 2033 人见人爱A+B
2015-07-20 17:25:40 来源: 作者: 【 】 浏览:3
Tags:HDOJ 2033

人见人爱A+B

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


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

Author lcy
Source ACM程序设计期末考试(2006/06/07)
Recommend lcy | We have carefully selected several similar problems for you: 2034 2032 2035 2096 2039


#include 
  
   
using namespace std;
int main(){
	int n;
	cin >> n;
	while (n--){
		int h1, m1, s1;
		int h2, m2, s2;
		int h3, m3, s3;
		cin >> h1 >> m1 >> s1;
		cin >> h2 >> m2 >> s2;
		s3 = s1 + s2;
		m3 = m1 + m2;
		h3 = h1 + h2;
		if (s3 >= 60){
			s3 -= 60;
			m3++;
		}
		if (m3 >= 60){
			m3 -= 60;
			h3++;
		}
		cout << h3 << " " << m3 << " " << s3 << endl;
	}
}
  


Statistic | Submit | Discuss | Note
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Codeforces Round #274 A. Expres.. 下一篇HDU 1827 Summer Holiday(强连通..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)
·MySQL 数据类型:从 (2025-12-26 18:20:03)
·Linux Shell脚本教程 (2025-12-26 17:51:10)
·Qt教程,Qt5编程入门 (2025-12-26 17:51:07)