CodeForces 387A George and Sleep
来源:互联网 发布:知乎书店实体店 编辑:程序博客网 时间:2024/05/18 20:35
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for timet.
Help George! Write a program that will, given time s andt, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).
The first line contains current time s as a string in the format "hh:mm". The second line contains timet in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is,00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.
In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.
05:5005:44
00:06
00:0001:00
23:00
00:0100:00
00:01
In the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06", "00:6" and others will be considered incorrect.
In the second sample, George went to bed yesterday.
In the third sample, George didn't do to bed at all.
#include<cstdio>#include<iostream>using namespace std;int main(){ int a,b,c,d,t1,t2; while(scanf("%d:%d",&a,&b)!=EOF){ scanf("%d:%d",&c,&d); t1=b-d; t2=a-c; if(t1<0){ t1+=60; t2-=1; } if(t2<0){ t2+=24; } printf("%02d:%02d\n",t2,t1); } return 0;}
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- Codeforces 387A George and Sleep
- codeforces George and Sleep
- A. George and Sleep
- A. George and Sleep
- Codeforces Round #227 (Div. 2)A. George and Sleep
- Codeforces Round #227 (Div. 2)---A. George and Sleep
- Codefoces 387A George and Sleep(水题)
- George and Sleep
- . George and Sleep
- George and Sleep
- George and Sleep
- Codeforces 467A George and Accommodation
- Codeforces 467A George and Accommodation(水题)
- Problem-467A-Codeforces-George and Accommodation
- codeforces 467A George and Accommodation
- 计算机网络:传输层
- eclipse设置自动提示功能
- Android WebView 获取网页数据(html)
- eclipse设置自动注释
- 更改错误提示等级
- CodeForces 387A George and Sleep
- 知道这20个正则表达式,能让你少写1,000行代码
- applciation.xml foundation configuration and description
- Android 命名规则
- fixed 实现div居中
- 转:在Eclipse中关联Android Private Libraries中文件的源代码
- NoSQL的理解
- 排序算法-希尔排序
- linux命令---删除一个目录下的所有文件,但保留一个指定文件