2020牛客多校第二场D题Duration(签到题)

题意:给你两个用24时间表示的时间,输出相差多少秒,坑点23:59:59到0:0:0是86399秒

#include<iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=1e5+7; 

int main(){
    int a,b,c;
    int x,y,z;
    scanf("%d:%d:%d",&a,&b,&c);
    scanf("%d:%d:%d",&x,&y,&z);
    //cout<<a<<b<<c<<endl;
    if(z<c) {
        z+=60;
        y--;
    }
    if(b<y){
        y+=60;
        x--;
    }
    long long  ans=(z-c)+(y-b)*60+(x-a)*3600;
    if(ans<0) ans=-ans;
    printf("%lld\n",ans);
    return 0;
}
View Code

 

posted @ 2020-08-01 09:25  杰瑞与汤姆  阅读(110)  评论(0编辑  收藏  举报