https://codeforces.com/contest/1066/problem/A
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Vova plans to go to the conference by train. Initially, the train is at the point 1 and the destination point of the path is the point L. The speed of the train is 1 length unit per minute (i.e. at the first minute the train is at the point 1, at the second minute — at the point 2 and so on).
There are lanterns on the path. They are placed at the points with coordinates divisible by v (i.e. the first lantern is at the point v, the second is at the point 2v and so on).
There is also exactly one standing train which occupies all the points from l to r inclusive.
Vova can see the lantern at the point p if p is divisible by v and there is no standing train at this position (p∉[l;r]). Thus, if the point with the lantern is one of the points covered by the standing train, Vova can't see this lantern.
Your problem is to say the number of lanterns Vova will see during the path. Vova plans to go to t different conferences, so you should answer t independent queries.
Input
The first line of the input contains one integer t (1≤t≤104) — the number of queries.
Then tt lines follow. The i-th line contains four integers Li,vi,li,ri (1≤L,v≤109, 1≤l≤r≤L) — destination point of the i-th path, the period of the lantern appearance and the segment occupied by the standing train.
Output
Print t lines. The i-th line should contain one integer — the answer for the i-th query.
Example
input
4 10 2 3 7 100 51 51 51 1234 1 100 199 1000000000 1 1 1000000000
output
3 0 1134 0
Note
For the first example query, the answer is 3. There are lanterns at positions 2, 4, 6, 8 and 10, but Vova didn't see the lanterns at positions 4 and 6 because of the standing train.
For the second example query, the answer is 0 because the only lantern is at the point 51 and there is also a standing train at this point.
For the third example query, the answer is 1134 because there are 1234 lanterns, but Vova didn't see the lanterns from the position 100 to the position 199 inclusive.
For the fourth example query, the answer is 0 because the standing train covers the whole path.
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
using namespace std;
typedef long long ll;
const int N=10000;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m;
int L,v,l,r;
int main()
{
#ifdef DEBUG
freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
#endif
scanf("%d",&t);
while(t--){
scanf("%d%d%d%d",&L,&v,&l,&r);
int ans=(l-1)/v;
ans+=(L/v)-(r/v);
cout << ans << endl;
}
//cout << "Hello world!" << endl;
return 0;
}