Result: Accepted
Time: 6ms
Memory: 1712kB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;
const int maxn = 1e4+7;
char Time[10];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,Ta,b,Tb;
int h,m;
scanf("%d %d",&a,&Ta);
scanf("%d %d",&b,&Tb);
scanf("%s",Time);
h = (Time[0] - '0' )* 10 + Time[1] - '0';
m = (Time[3] - '0' )* 10 + Time[4] - '0';
int tot = h * 60 + m;
int st = tot - Tb;
int en = tot + Ta;
//printf("%d %d\n",st,en);
int ans = 0;
for(int i=300;i<=23 * 60 + 59;i += b)
{
if(i > st && i < en) {
ans++;
//cout<<i<<endl;
}
}
printf("%d\n",ans);
}
}