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: 7ms
Memory: 1092kB
Author: 2018212212029
In contest: 1289

#include<stdio.h>
#include<string.h>
int main() {
	int t;
	int t1,t2,ans;
	int a,ta,b,tb,tr,tr2,x,y;
	scanf("%d",&t);
	while(t--) {
		ans=0;
		scanf("%d%d%d%d",&a,&ta,&b,&tb);
		scanf("%d:%d",&t1,&t2);
//		if(t1>=5&&((t1-5)*60+t2)%b==0) ++ans;
		if(t1<5) {
			ta=ta-(5-t1)*60+t2;
			if(ta%b==0) printf("%d\n",ta/b);
			else printf("%d\n",ta/b+1);
		} else {
			//if((23-t1)*60+59-t2<ta) ta=(23-t1)*60+59-t2+1;
			//if((t1-5)*60+t2<tb) tb=(t1-5)*60+t2-1;
			int f=t1*60+t2;
			for(int i=300; i<1440; i+=b) {
				if(i>f-tb&&i<f+ta) ++ans;
			}
			printf("%d\n",ans);
		}
		/*ans+=ta/b;
		ans+=tb/b;
		if(tb%b==0&&y==tb) ans--;
		if(ta%b==0&&x==ta) ans--;
		printf("%d\n",ans);*/
	}
}