Result: Accepted
Time: 4ms
Memory: 1756kB
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <deque>
#define clr(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
const int maxn=1e4+10;
int t;
int a,ta,b,tb;
int start;
string s;
int main()
{
cin>>t;
while(t--)
{
cin>>a>>ta>>b>>tb;
cin>>s;
start=(((int)s[0]-48)*10+(int)s[1]-48)*60+(int)(s[3]-48)*10+(int)s[4]-48;
int down=start-tb,up=start+ta,ans=0;
for(int i=300;i<=23*60+59;i+=b)
{
if(i>down&&i<up)ans++;//==的时候刚好在a||b相遇
}
cout<<ans<<endl;
}
}