Wannafly挑战赛8-小Y和小B睡觉觉

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37185692/article/details/79110584
时间限制: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
 
      
#include <iostream>
#include <cstdio>
using namespace std;
 
int main()
{
    long long int n,flag,flag1;
    int year,month,day,h,m,s;
    scanf("%d-%d-%d %d:%d:%d",&year,&month,&day,&h,&m,&s);
    cin>>n;
    flag=n/(3600*24);
    flag1=n%(3600*24);
    if(h*3600+m*60+s+flag1>=3600*24)
    {
        flag+=1;
    }
    cout << flag << endl;
    return 0;
}


猜你喜欢

转载自blog.csdn.net/m0_37185692/article/details/79110584