[2033 ] :人见人爱A+B
来源:互联网 发布:idc联想数据 编辑:程序博客网 时间:2024/06/18 16:57
人见人爱A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32517 Accepted Submission(s): 21619
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<stdio.h>int main(){ int n; while(scanf("%d", &n)!=EOF){ while(n){ int i, str[6]; for(i=0; i<6; i++){ scanf("%d", &str[i]); } int second = (str[2]+str[5])-(str[2]+str[5])/60*60; int minute = str[1]+str[4]+(str[2]+str[5])/60-(str[1]+str[4]+(str[2]+str[5])/60)/60*60; int hour = str[0]+str[3]+(str[1]+str[4]+(str[2]+str[5])/60)/60; printf("%d %d %d\n", hour, minute, second); n--; } } return 0;}
为了增强可读性,可以改成如下代码:
#include<stdio.h>int main(){ int n; while(scanf("%d", &n)!=EOF){ while(n){ int i, str[6]; for(i=0; i<6; i++){ scanf("%d", &str[i]); } int secIntoMin = (str[2]+str[5])/60; int second = (str[2]+str[5])- secIntoMin*60; int minIntoHour = (str[1]+str[4]+(str[2]+str[5])/60)/60; int minute = str[1]+str[4]+(str[2]+str[5])/60 - minIntoHour*60; int hour = str[0]+str[3] + (str[1]+str[4]+(str[2]+str[5])/60)/60; printf("%d %d %d\n", hour, minute, second); n--; } } return 0;}
0 0
- 2033 人见人爱A+B
- 2033 人见人爱A+B
- 人见人爱A+B(2033)
- 2033 人见人爱A+B
- 2033 人见人爱A+B
- [2033 ] :人见人爱A+B
- 2033 人见人爱A+B
- hdu 2033 人见人爱A+B
- HDU 2033 人见人爱A+B
- HDU-2033人见人爱A+B
- HDU 2033 人见人爱A+B
- HDU 2033 人见人爱A+B
- hdu-2033-人见人爱A+B
- HDU 2033 - 人见人爱 A + B
- hdu 2033 人见人爱A+B
- [hdu 2033] 人见人爱A+B
- HDUJ 2033 人见人爱A+B
- hdu-2033-人见人爱A+B
- git删除文件所有历史版本
- 工欲善其事,必先利其器--phper的sublime text3
- ERP见面会
- 静态Static(C#)
- leetcode 48:Rotate Image
- [2033 ] :人见人爱A+B
- JUnit4入门
- LeetCode Add Two Numbers(用链表模拟加法)
- 驱动模块和桩模块的概念和区别
- c++primer第五版第十二章12.20习题用一个StrBlobPtr打印出StrBlob中的元素
- Odd-even sort: Sorting by Exchanging
- opencv笔记 1.利用摄像头进行视频文件写入
- sicily 14550 Interesting Integers
- 模板 poj2947 Widget Factory 高斯消元