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: 2017212212174
In contest: 1277

#include<stdio.h>
int main() {
	int a, ta, b, tb, t, T;
	scanf("%d", &T);
	while (T--) {
		int h, m, right, left, n, date = 0;
		scanf("%d%d%d%d", &a, &ta, &b, &tb);
		scanf("%d:%d", &h, &m);
		t = h * 60 + m;
		t -= 300;
		left = t - tb;
		right = t + ta;
		if (left < 0)left = -1;
		if (right > 1139)right = 1140;
		for (n = left + 1; n < right; n++) {
			if (!(n%b))date++;
		}
		printf("%d\n", date);
	}
	return 0;
}