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: 5936kB
Author: 2018212212127
In contest: 1289

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn=1e4+10;
int a[maxn][107],b[maxn];
int dir[4][2]={1,0,0,1,-1,0,0,-1};
struct rule{
	bool operator()(const int &a1,const int &a2){
		return a1>a2;
	}
};
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int a,Ta,b,Tb,h,m,tot=0,t1,t2;
		scanf("%d %d %d %d",&a,&Ta,&b,&Tb);
		scanf("%d:%d",&h,&m);
//		if(((h-5)*60+m)%a==0) tot++;
		t1=(h-5)*60+m-Tb;
		if(t1<0) t1=0,tot++;
		else if(t1==0) t1+=Tb;
		t2=(h-5)*60+m+Ta;
		t2=min(t2,59+18*60);
		if(t2%b==0) tot--;
		tot+=t2/b-t1/b;
		printf("%d\n",tot);
	}
	
}