Educational Codeforces Round 12 A.Busses Between Cites水題

1911 ワード

A.Busses Between Cites
テーマ接続:
http://www.codeforces.com/contest/665/problem/A
Description
Busses run between the cities A and B,the first one ist 05:00 AM and the last one departs not later than at 11:59 PM.A bus from the city A des party a minutes and arrives the city B
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 counting.
Input
The first line contains two integers a、𔎅ta(1̵≦𔎅a、_;ta≤𔎅120)-the frequency of the buses from the city A the travel time.vagies.vents.
The second line contains two integers b、𔎅tb(1̵≦𔎅b、𔎅tb≦𔎅120)-the frequency of the buses from the city B to the trable.Bogivents.vaties.
The last line contains the departure time of Simion from the city A in the format hh:mm.It is garanted that the re the the the city A at.Note that the hors and the minutes are givent the givent。
Output
Print the only integer z-the number of buses Simion will meet on on the way.Note that you shout not count the encounters in cities A and B.
Sample Input
10 30 10 35:20
Sample Output
5
ベント
題意
二つの都市AとBがあります。
A分ごとに車を出します。この車は歩いてA秒でBに着きます。
B分ごとに車を出します。この車はTB秒でAに着きます。
二つの都市は朝5時から出発します。11時に発車します。
子供がいます。AからBまでの列車に乗って、どれぐらいの車が見られますか?
クイズ:
見た車は明らかにこの車が動いている間に、B地で発車した車とまだ来ていない車です。
そして暴力があればいいです。
コード
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,ta,b,tb;
    scanf("%d%d%d%d",&a,&ta,&b,&tb);
    int h,m;scanf("%d:%d",&h,&m);
    m+=60*h;
    int ans = 0;
    for(int i=300;i<24*60;i+=b)
        if(i+tb>m&&i<m+ta)ans++;
    cout<<ans<<endl;
}