
3 1 1 1 1 1 1 2 1 1 1 3 1
1 2 -1
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
int a;
int main()
{
int t;
int x,y,l,h;
while(cin>>t)
{
while(t--)
{
cin>>x>>y>>l>>h;
if(l%x==0)
{
h=h-(l/x-1)*y;
if(h>=0)
{
cout<<l/x<<endl;
}
else
{
puts("-1");
}
}
else
{
h=h-(l/x)*y;
if(h>=0)
{
cout<<l/x+1<<endl;
}
else
{
puts("-1");
}
}
}
}
return 0;
}
2015苏州大学ACM-ICPC集训队选拔赛(1) 1008
原文:http://www.cnblogs.com/yinghualuowu/p/5076893.html