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: 3ms
Memory: 1120kB
Author: 2018212212125
In contest: 1289

#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn = 10010;
const int inf = 0x3f3f3f3f;
int  n, m, N, t;
int main()
{
	scanf("%d", &t);
	while (t--)
	{
		int a, ta, b, tb, th, tm;
		scanf("%d %d %d %d", &a, &ta, &b, &tb);
		scanf("%d:%d", &th, &tm);
		int ans = 0;
		n = th * 60 + tm;
		m = n + ta;
		if (m > 23 * 60 + 59)
			m = 23 * 60 + 59;
		else
			m--;
		n -= tb;
		if (n < 5 * 60)
			n = 5 * 60;
		else
			n++;
		if ((n - 5 * 60) % b == 0)
			ans++;
		ans += (m - 5 * 60) / b - (n - 5 * 60) / b;
		printf("%d\n", ans);

	}
	return 0;
}