题库练习 Vova and Train
← 上一题 下一题 →

A12264 | Vova and Train

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 \not\in [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.

输入格式

The first line of the input contains one integer $t$ ( $1 \le t \le 10^4$ ) — the number of queries.

Then $t$ lines follow. The $i$ -th line contains four integers $L_i, v_i, l_i, r_i$ ( $1 \le L, v \le 10^9$ , $1 \le l \le r \le L$ ) — destination point of the $i$ -th path, the period of the lantern appearance and the segment occupied by the standing train.

输出格式

Print $t$ lines. The $i$ -th line should contain one integer — the answer for the $i$ -th query.

输入输出样例

输入 #1
4
10 2 3 7
100 51 51 51
1234 1 100 199
1000000000 1 1 1000000000
输出 #1
3
0
1134
0
C++ 编辑器
输入
输出