CodeForces Round #515 Div.3 A. Vova and Train
http://codeforces.com/contest/1066/problem/A
Vova plans to go to the conference by train. Initially, the train is at the point 11 and the destination point of the path is the point LL. The speed of the train is 11 length unit per minute (i.e. at the first minute the train is at the point 11, at the second minute — at the point 22 and so on).
There are lanterns on the path. They are placed at the points with coordinates divisible by vv (i.e. the first lantern is at the point vv, the second is at the point 2v2v and so on).
There is also exactly one standing train which occupies all the points from ll to rr inclusive.
Vova can see the lantern at the point pp if pp is divisible by vv and there is no standing train at this position (p∉[l;r]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 tt different conferences, so you should answer tt independent queries.
The first line of the input contains one integer tt (1≤t≤1041≤t≤104) — the number of queries.
Then tt lines follow. The ii-th line contains four integers Li,vi,li,riLi,vi,li,ri (1≤L,v≤1091≤L,v≤109, 1≤l≤r≤L1≤l≤r≤L) — destination point of the ii-th path, the period of the lantern appearance and the segment occupied by the standing train.
Print tt lines. The ii-th line should contain one integer — the answer for the ii-th query.
4
10 2 3 7
100 51 51 51
1234 1 100 199
1000000000 1 1 1000000000
3
0
1134
0
For the first example query, the answer is 33. There are lanterns at positions 22, 44, 66, 88 and 1010, but Vova didn't see the lanterns at positions 44and 66 because of the standing train.
For the second example query, the answer is 00 because the only lantern is at the point 5151 and there is also a standing train at this point.
For the third example query, the answer is 11341134 because there are 12341234 lanterns, but Vova didn't see the lanterns from the position 100100 to the position 199199 inclusive.
For the fourth example query, the answer is 00 because the standing train covers the whole path.
代码:
#include <bits/stdc++.h>
using namespace std; int T;
int L, v, l, r;
int cnt; int main() {
scanf("%d", &T);
while(T --) {
cnt = 0;
scanf("%d%d%d%d", &L, &v, &l, &r);
cnt = L / v - r / v + (l - 1) / v;
printf("%d\n", cnt);
}
return 0;
}
CodeForces Round #515 Div.3 A. Vova and Train的更多相关文章
- Codeforces Round #515 (Div. 3)
Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cs ...
- Codeforces Round #515 (Div. 3) 解题报告(A~E)
题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...
- CodeForces Round #515 Div.3 B. Heaters
http://codeforces.com/contest/1066/problem/B Vova's house is an array consisting of nn elements (yea ...
- A. Vova and Train ( Codeforces Round #515 (Div. 3) )
题意:一条 L 长的路,一列车长在这条路的 l 到 r 之间,只有在 v 倍数时有灯,但是在 l 到 r 之间的灯是看不见的,问最大看见的灯的个数? 题解:L / v 表示总共的灯的个数, r / v ...
- Codeforces Round #515 (Div. 3) B. Heaters【 贪心 区间合并细节 】
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limi ...
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...
- CodeForces Round #515 Div.3 D. Boxes Packing
http://codeforces.com/contest/1066/problem/D Maksim has nn objects and mm boxes, each box has size e ...
- CodeForces Round #515 Div.3 C. Books Queries
http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. ...
- CodeForces Round #515 DIv.3 F. Yet another 2D Walking
http://codeforces.com/contest/1066/problem/F Maksim walks on a Cartesian plane. Initially, he stands ...
随机推荐
- centos install rtl8188ce driver
1.导入公钥,注意大小写. rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org 2.安装ELRepo库. rpm -Uvh http://elr ...
- caffe的损失函数
损失函数,一般由两项组成,一项是loss term,另外一项是regularization term. J=L+R 先说损失项loss,再说regularization项. 1. 分对得分1,分错得分 ...
- 前端HTML基础
1.0开发工具介绍 sublime的使用技巧链接 HTML特殊符号表 1.1 html概念 超文本标记语言(Hypertext Markup Language),属于一种描述性的标记语言(markup ...
- 关于package.json学习
1.如果要下载npm包,必须有package.json文件,不然会报错,如果缺少必要字符报错,参考报错信息 2.license,指定用户权限,可以不写,不会报错 3.devDependencies,依 ...
- javascript入门笔记6-内置对象
1.Date 日期对象 日期对象可以储存任意一个日期,并且可以精确到毫秒数(1/1000 秒). 定义一个时间对象 : var Udate=new Date(); 注意:使用关键字new,Date() ...
- POJ的层次感分类
转载自:[http://blog.csdn.net/zzycsx/article/details/49103451] OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,po ...
- What is JPA
What is JPA JPA可以看做是EJB3.0的一部分,但它又不限于EJB 3.0,你可以在Web应用.甚至桌面应用中使用.JPA只是一种Java持久化标准,它意在规范ORM(对象关系映射模型) ...
- JQuery实现子级选择器
效果图如下: HTML代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- windows下使用curl.exe模拟ajax请求
curl 是一般linux发行版中都带有的小工具,利用这个工具可以很方便的下载文件,我一般使用这个工具来查看某个页面相应的HTTP头信息,在Windows系统中我们也一样可以使用这个工具,如果不需要支 ...
- 微信小程序禁止下拉_解决小程序下拉出现空白的情况
微信小程序禁止下拉 在微信小程序中,用力往下拉动,页面顶部会出现一段空白的地方. 产品的需求不太允许这么做,会影响用户体验,查看文档发现可以使用enablePullDownRefresh这属性来实现, ...