牛客网 Wannafly挑战赛8 A.小Y和小B睡觉觉

写了一会不想写了。。。

A-小Y和小B睡觉觉

链接:https://www.nowcoder.com/acm/contest/57/A
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld

 

题目描述

Brother Ya和Brother Bo现在要开始睡觉啦!
假设当前的时间为yyyy-mm-dd hh:mm:ss,他们两个会一觉睡t秒,请问他们睡醒的时刻是几天以后(过了晚上12点就算一天)?

输入描述:

第一行一个字符串表示时间(2018年的某一天)
第二行一个数字t表示秒数(1 <= t <= 10,000,000)

输出描述:

输出一个整数表示答案。
示例1

输入

2018-01-16 06:59:59 
86400

输出

1
示例2

输入

2018-01-16 23:59:59 
1

输出

1

不好玩

代码:

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 using namespace std;
 5 int main(){
 6     int y,m,d,hh,mm,ss;
 7     int t;
 8     while(~scanf("%d-%d-%d%d:%d:%d",&y,&m,&d,&hh,&mm,&ss)){
 9         scanf("%d",&t);
10         t+=ss;
11         t/=60;
12         if(t){
13             t+=mm;
14             t/=60;
15             int day=0;
16             if(t){
17                 t+=hh;
18                 t/=24;
19                 if(t)printf("%d
",t);
20                 else printf("0
");
21             }
22         }
23     }
24     return 0;
25 }


原文地址:https://www.cnblogs.com/ZERO-/p/8329535.html