codeforces 665A Buses Between Cities

简单题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

int a,ta,b,tb;
int hh,mm;

int f(int st,int en,int ss,int ee)
{
    if(ee<=st) return 0;
    if(en<=ss) return 0;
    return 1;
}

int main()
{
    scanf("%d%d",&a,&ta);
    scanf("%d%d",&b,&tb);
    scanf("%d:%d",&hh,&mm);

    int st=hh*60+mm;
    int en=hh*60+mm+ta;

    int t=0;
    int ans=0;

    while(1)
    {
        int ss=5*60+t*b;
        int ee=ss+tb;
        if(ss>=24*60) break;
        if(f(st,en,ss,ee)==1) ans++;
        t++;
    }

    printf("%d\n",ans);
    return 0;
}

 

posted @ 2016-06-30 17:40  Fighting_Heart  阅读(180)  评论(0编辑  收藏  举报