hi.精密计时

[信息与未来 2023] 精密计时

题目描述

小小有一个非常精密的计时器,每秒可以计数 100 次 (两个连续的时钟计数之间恰好间隔百分之一秒)。例如,以下是从 13 : 01 : 02.37 13:01:02.37 13:01:02.37 13 : 01 : 03.01 13:01:03.01 13:01:03.01 的计时过程:

13:01:02.37 (13 时 1 分 2 秒.37)
13:01:02.38
13:01:02.39
...
13:01:02.98
13:01:02.99 (13 时 1 分 2 秒.99)
13:01:03.00 (13 时 1 分 3 秒.00)
13:01:03.01

小小记录了计时器上的两个时刻,你能帮助他计算这两个时刻之间经过了多少个 “百分之一秒”吗?

输入格式

输入数据仅一行,包含空格分开的两个字符串,代表了两个计时器上显示的时刻。时刻中的时、分、秒、百分之一秒均使用两位十进制数字表示,不足两位时在十位添零。时、分、秒之间用冒号 : 分隔,秒和百分之一秒之间用小数点 . 分隔。

输出格式

输出一行一个整数,代表两个时刻之间经过的 “百分之一秒” 数。

样例 #1

样例输入 #1

01:02:34.56 01:03:00.10

样例输出 #1

2554

样例 #2

样例输入 #2

00:00:00.00 23:59:59.99

样例输出 #2

8639999

提示说明

在这里插入图片描述

对于 100 % 100\% 100% 的数据,两个时刻都来自 24 24 24 小时制的同一天 ( 00 : 00 : 00.00 00:00:00.00 00:00:00.00 23 : 59 : 59.99 23:59:59.99 23:59:59.99),且保证后一个时刻晚于前一个时刻。

本题原始满分为 15 pts 15\text{pts} 15pts

代码内容

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef struct time
{
    int h,m,s,f;
}per;

int main()
{
    per st,ed;
    
    int a,b,c,d;
    scanf("%d:%d:%d.%d",&a,&b,&c,&d);
    st={a,b,c,d};

    int x,y,z,k;
    scanf("%d:%d:%d.%d",&x,&y,&z,&k);
    ed={x,y,z,k};

    ll times=0;
    if(ed.f>=st.f)
        times+=ed.f-st.f;
    else
    {
        ed.s--;
        times+=ed.f+100-st.f;
    }
    
    if(ed.s>=st.s)
        times+=(ed.s-st.s)*100;
    else
    {
        ed.m--;
        times+=(ed.s+60-st.s)*100;
    }
    
    if(ed.m>=st.m)
        times+=(ed.m-st.m)*60*100;
    else
    {
        ed.h--;
        times+=(ed.m+60-st.m)*60*100;
    }
    
    if(ed.h>=st.h)
        times+=(ed.h-st.h)*60*60*100;

    cout<<times<<endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值