FJNU 1155 Fat Brother’s prediction(胖哥的预言)
FJNU 1155 Fat Brother’s prediction(胖哥的预言)
Time Limit: 1000MS Memory Limit: 257792K
|
【Description】 |
【题目描述】 |
|
Fat Brother is a famous prophet, One day he get a prediction that disaster will come after X days. He is too nervous that sudden die. Fortunately he leave a note about number X after he died: X is a number of integer which can divided exactly by Y range in [L, R] You want to know what X is. |
胖哥是一位大神棍,一天他得到一条预言昭示着大灾变会在X天后降临。结果分分钟就把他给吓死了。好在他死后留有一谶可以解X: X是[L, R]中可以被Y整除的整数数量 你试图解出X为何。 |
|
【Input】 |
【输入】 |
|
There are multiple test cases. The first line of input contains an integer T (T <= 10000) indicating the number of test cases. For each test case: Contain 3 integer L, R, Y (1 <= L <= R <= 2^63 - 1, 1 <= Y <= 2^63 - 1) |
多组测试用例。 第一行是一个整数T(T <= 10000)表示测试用例的数量。对于每个测试用例: 有三个整数L, R, Y (1 <= L <= R <= 2^63 - 1, 1 <= Y <= 2^63 - 1) |
|
【Output】 |
【输出】 |
|
Each case print a number X. |
输出每个样例的数字X。 |
|
【Sample Input - 输入样例】 |
【Sample Output - 输出样例】 |
|
2 1 3 2 3 10 3 |
1 3 |
|
【Hint】 |
【提示】 |
|
First case [1, 3] has number [1, 2, 3], only 2 can divided exactly 2. So answer is 1 Second case [3, 10] has number [3, 4, 5, 6, 7, 8, 9, 10], number 3, 6, 9 can divided exactly 3, So answer is 3 |
第一个样例 [1, 3]拥有数字[1, 2, 3],只有2可以被2整除。所以答案为1 第二个样例 [3, 10]拥有数字[3, 4, 5, 6, 7, 8, 9, 10],数字3, 6, 9可被3整除,所以答案为3 |
【题解】
题目要求[L, R]中有几个数能被Y整除
转化一下:求[L, R]中有多少Y的倍数
X = [0, R]中Y倍数的个数 - [0, L-1]中Y倍数的个数
即X = R/Y – (L-1)/Y
(由于不是数学意义上的乘法,合并后会被余数干扰……作死)
【代码 C++】
#include<cstdio>
int main(){
int t, n;
long long L, R, Y;
while (~scanf("%d", &t)){
while (t--){
scanf("%lld%lld%lld", &L, &R, &Y);
printf("%lld\n", R / Y - (L - ) / Y);
}
}
return ;
}
FJNU 1155 Fat Brother’s prediction(胖哥的预言)的更多相关文章
- FJNU 1154 Fat Brother And His Love(胖哥与女神)
FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1153 Fat Brother And XOR(胖哥与异或)
FJNU 1153 Fat Brother And XOR(胖哥与异或) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目描述] ...
- FJNU 1152 Fat Brother And Integer(胖哥与整数)
FJNU 1152 Fat Brother And Integer(胖哥与整数) Time Limit: 1000MS Memory Limit: 257792K [Description] [题 ...
- FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- FJNU 1151 Fat Brother And Geometry(胖哥与几何)
FJNU 1151 Fat Brother And Geometry(胖哥与几何) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)
FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS Memory Limit: 257792K [Description ...
- FJNU 1159 Fat Brother’s new way(胖哥的新姿势)
FJNU 1159 Fat Brother’s new way(胖哥的新姿势) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- HDU 4637 Rain on your Fat brother 线段与半圆和线段交 简单题
题意: 应该不难读懂. 做法: 我们可以把雨滴看做静止不动,然后maze(这题的那个人)就是往左上方运动就可以了,计算出maze能跑到的最远的点,然后就是求起点和终点所构成的线段与每个雨滴交的时间,注 ...
- 大数据的胖哥的方式(9)- 金融业数据仓库的逻辑模型FS-LDM
介绍: 大数据是不是海市蜃楼,来自小橡子只是意淫奥克斯,大数据的发展,而且要从头开始,基于大数据建设国家.项目-level数据中心行业将越来越多,大数据仅供技术,而非溶液,临数据组织模式,数据逻辑模式 ...
随机推荐
- CentOS 7安装Gnome GUI 图形界面
当你安装centos服务器版本的时候,系统默认是不会安装 CentOS 的图形界面程序的,比如:gnome或者kde, 那么如果你想在图形界面下工作的话,可以手动来安装CentOS Gnome GUI ...
- ecshop第一讲之安装
今天开始对Ectouch做一些研究,但是发现网上资源很少,而且官网对服务都需收费:并且提供的wiki.官方文档等都是空的,瞬间感觉,,,,后来开始海量搜索,最后发现只有论坛还有些东西可以看看,并对海量 ...
- AtomicInteger类保证线程安全的用法
J2SE 5.0提供了一组atomic class来帮助我们简化同步处理.基本工作原理是使用了同步synchronized的方法实现了对一个long, integer, 对象的增.减.赋值(更新)操作 ...
- 使用KNN对MNIST数据集进行实验
由于KNN的计算量太大,还没有使用KD-tree进行优化,所以对于60000训练集,10000测试集的数据计算比较慢.这里只是想测试观察一下KNN的效果而已,不调参. K选择之前看过貌似最好不要超过2 ...
- Ajax中GET和POST的区别
Get方式: 用get方式可传送简单数据,但大小一般限制在1KB下,数据追加到url中发送(http的header传送),也就是说,浏览器将各个表单字段元素及其数据按照URL参数的格式附加在请求行中的 ...
- Android WebView如何加载assets下的html文件
项目需求:将html文件以及所用到的图片都放在 assets/html/ 目录下.然后在页面上通过WebView来显示 直接付上代码: private void readHtmlFormAssets( ...
- 安装zeromq以及zeromq的python示例
下载ZeroMq: wget https://github.com/zeromq/zeromq4-1/releases/download/v4.1.5/zeromq-4.1.5.tar.gz 解压: ...
- 翻译之basename()
NAME top basename, dirname - parse pathname components SYNOPSIS top #include <libgen.h> char * ...
- mysql获取当前时间,及其相关操作
获取UNIX时间戳 : UNIX_TIMESTAMP(NOW()) 1.1 获得当前日期+时间(date + time)函数:now() 除了 now() 函数能获得当前的日期时间外,MySQL 中还 ...
- Python 主要模块和常用方法简览
******************** PY核心模块方法 ******************** 文件系统功能 os模块 目录: chdir() :改变工作目录 chroot ...