Start: Jul, 01, 2019 08:30:00
2019年度暑期短学期第四天
End: Jul, 01, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 3ms
Memory: 1120kB
Author: 2018212212320
In contest: 1277

#include<stdio.h>
int main()
{
	int t,n,m;
	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;
}