Start: Jun, 28, 2019 13:00:00
2019年度暑期短学期第四天-助教场
End: Jun, 30, 2019 23:59:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 9ms
Memory: 1712kB
Author: 2017212212167
In contest: 1289

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

int t, a, ta, b, tb, h, m;

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d %d", &a, &ta);
		scanf("%d %d", &b, &tb);
		scanf("%d:%d", &h, &m);
		int now = h * 60 + m;
		int end = now + ta -1;
		int maxx = 23 * 60 + 59;
		int start = 5 * 60;
		int ans = 0;
		for (int i = start; i <= end&&i<=maxx; i += b)
		{
			if (i + tb > now&&i<=end&&i<=maxx)
			{
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}