CF1066A.Vova and Train
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
沃瓦计划乘坐火车去参加会议。初始时,火车位于点 1,路径的终点为点 L。火车的速度为每分钟 1 个长度单位(即第 1 分钟时火车在点 1,第 2 分钟时在点 2,依此类推)。
路径上安装有灯笼。它们位于坐标能被 v 整除的点上(即第一盏灯笼在点 v,第二盏在点 2v,依此类推)。
路径上还恰好有一列静止的火车,它占据了从点 l 到点 r(含端点)的所有位置。
沃瓦能在点 p 处看见一盏灯笼,当且仅当 p 能被 v 整除,且该位置没有被静止的火车占据(即 p∈/[l;r])。因此,若某盏灯笼所在的位置恰好被静止火车覆盖,则沃瓦无法看见这盏灯笼。
你的任务是计算沃瓦在整段行程中能看到多少盏灯笼。沃瓦计划参加 t 场不同的会议,因此你需要回答 t 个相互独立的查询。
输入格式
The first line of the input contains one integer t (1≤t≤104) — the number of queries.
Then t 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.
输入的第一行包含一个整数 t(1≤t≤104)—— 查询次数。
接下来是 t 行。第 i 行包含四个整数 Li,vi,li,ri(1≤L,v≤109,1≤l≤r≤L)—— 分别表示第 i 条路径的目的地点、灯笼出现的周期,以及静止列车所占据的区间。
输出格式
Print t lines. The i-th line should contain one integer — the answer for the i-th query.
输出 t 行。第 i 行应包含一个整数——即第 i 个查询的答案。
输入输出样例
输入#1
4 10 2 3 7 100 51 51 51 1234 1 100 199 1000000000 1 1 1000000000
输出#1
3 0 1134 0
说明/提示
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.
对于第一个示例查询,答案是 3。灯笼位于位置 2、4、6、8 和 10,但由于停靠的列车遮挡,沃瓦没有看到位置 4 和 6 处的灯笼。
对于第二个示例查询,答案是 0,因为唯一的灯笼位于位置 51,而该位置恰好也有一列停靠的列车。
对于第三个示例查询,答案是 1134,因为一共有 1234 个灯笼,但沃瓦没有看到位置从 100 到 199(含端点)之间的所有灯笼。
对于第四个示例查询,答案是 0,因为停靠的列车覆盖了整条路径。
输入解题思路,AI测评打分。不知道怎么写?