zoukankan      html  css  js  c++  java
  • codeforces 665A A. Buses Between Cities(水题)

    题目链接:

    A. Buses Between Cities

    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output
     

    Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a ta minutes, and a bus from the city B departs every b minutes and arrives to the city A in a tb minutes.

    The driver Simion wants to make his job diverse, so he counts the buses going towards him. Simion doesn't count the buses he meet at the start and finish.

    You know the time when Simion departed from the city A to the city B. Calculate the number of buses Simion will meet to be sure in his counting.

     
    Input
     

    The first line contains two integers a, ta (1 ≤ a, ta ≤ 120) — the frequency of the buses from the city A to the city B and the travel time. Both values are given in minutes.

    The second line contains two integers b, tb (1 ≤ b, tb ≤ 120) — the frequency of the buses from the city B to the city A and the travel time. Both values are given in minutes.

    The last line contains the departure time of Simion from the city A in the format hh:mm. It is guaranteed that there are a bus from the city A at that time. Note that the hours and the minutes are given with exactly two digits.

     
    Output
     

    Print the only integer z — the number of buses Simion will meet on the way. Note that you should not count the encounters in cities Aand B.

     
    Examples
     
    input
    10 30
    10 35
    05:20
    output
    5
    input
    60 120
    24 100
    13:00
    output
    9
    Note

    In the first example Simion departs form the city A at 05:20 AM and arrives to the city B at 05:50 AM. He will meet the first 5 buses from the city B that departed in the period [05:00 AM - 05:40 AM]. Also Simion will meet a bus in the city B at 05:50 AM, but he will not count it.

    Also note that the first encounter will be between 05:26 AM and 05:27 AM (if we suggest that the buses are go with the sustained speed).

    题意:

    给出每隔多少分钟发车和经过多长时间到达目的地,为给的其中一辆车的发车时间,问这个车的司机能在路上遇到到多少辆车;

    思路:

    遇到的车都是到达时间在这辆车的发车时间之后和发车时间在这辆车到达时间之前的

    AC代码:

    /*2014300227    665A - 17    GNU C++11    Accepted    15 ms    2172 KB*/
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N=1e5+5;
    const ll mod=1e9+7;
    int a,ta,b,tb;
    char str[10],s;
    int main()
    {
        scanf("%d%c%d",&a,&s,&ta);
        scanf("%d%c%d",&b,&s,&tb);
        scanf("%s",str);
        int start=((str[0]-'0')*10+(str[1]-'0'))*60+(str[3]-'0')*10+(str[4]-'0');
        int ending=start+ta;
        int l=300,r=24*60-1;
        int ans=0;
        for(int i=l;i<=r;i+=b)
        {
            if(i+tb>start&&i<ending)ans++;
        }
        cout<<ans<<"
    ";
        return 0;
    }
  • 相关阅读:
    “猫癣”集团借IE7新漏洞再掀风浪 狼人:
    研究人员在黑帽安全大会演示SSL攻击 狼人:
    猫癣病毒“躲猫猫” 移师广东东莞月入百万 狼人:
    Adobe两款软件存在缺陷 黑客可控制用户PC 狼人:
    安全观点:遭遇数据泄露破坏 损失的不只是金钱 狼人:
    McAfee报告称七成手机制造商认为手机安全至关重要 狼人:
    微软表示本月将发布五个Windows 7更新 狼人:
    Gmail电子邮件曝全球性故障 谷歌向用户道歉 狼人:
    Google Talk被黑客利用 发动钓鱼攻击 狼人:
    谷歌GMail邮件服务出现故障 部分服务已恢复 狼人:
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5415736.html
Copyright © 2011-2022 走看看