当前位置:网站首页>[牛客] B-完全平方数
[牛客] B-完全平方数
2022-07-06 17:14:00 【*DDL_GzmBlog】
前言
使用stl的二分,最好最好最好最好下标要从0开始啊
t a g : tag : tag:二分数学
题意 :
思路 :
l ≤ x ≤ r l\le x \le r l≤x≤r
l ≤ x ≤ r \sqrt l \le \sqrt x \le \sqrt r l≤x≤r
又因为 l , r ≤ 1 0 9 l,r\le10^9 l,r≤109因此我们可以预处理出 x \sqrt x x数组
最后通过二分确定开方区间,开方区间的大小就是答案
code :
int a[N];
int i;
void init(){
Fup(i,1,1e5)a[i] = i;
}
void solve(){
int l,r;cin>>l>>r;
int n = 1e5;
int L = lower_bound(a+1,a+1+n,sqrt(l)) - a;
int R = upper_bound(a+1,a+1+n,sqrt(r)) - a;
cout<<max(R-L,0)<<endl;
}
int main(){
init();
int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- Advanced learning of MySQL -- basics -- multi table query -- subquery
- Attention SLAM:一种从人类注意中学习的视觉单目SLAM
- Part IV: STM32 interrupt control programming
- Dell筆記本周期性閃屏故障
- Advanced learning of MySQL -- basics -- multi table query -- external connection
- Leetcode (547) - number of provinces
- STM32开发资料链接分享
- mongodb客户端操作(MongoRepository)
- How do novices get started and learn PostgreSQL?
- Mujoco finite state machine and trajectory tracking
猜你喜欢
![Explain in detail the matrix normalization function normalize() of OpenCV [norm or value range of the scoped matrix (normalization)], and attach norm_ Example code in the case of minmax](/img/87/3fee9e6f687b0c3efe7208a25f07f1.png)
Explain in detail the matrix normalization function normalize() of OpenCV [norm or value range of the scoped matrix (normalization)], and attach norm_ Example code in the case of minmax

【软件逆向-自动化】逆向工具大全

Dell Notebook Periodic Flash Screen Fault

stm32F407-------DAC数模转换

How to judge whether an element in an array contains all attribute values of an object

迈动互联中标北京人寿保险,助推客户提升品牌价值

第六篇,STM32脉冲宽度调制(PWM)编程

windows安装mysql8(5分钟)

Stm32f407 ------- SPI communication

Lombok 同时使⽤ @Data 和 @Builder 的坑,你中招没?
随机推荐
Installation and testing of pyflink
Part IV: STM32 interrupt control programming
Alexnet experiment encounters: loss Nan, train ACC 0.100, test ACC 0.100
学习使用代码生成美观的接口文档!!!
Five different code similarity detection and the development trend of code similarity detection
通过串口实现printf函数,中断实现串口数据接收
windows安装mysql8(5分钟)
学习光线跟踪一样的自3D表征Ego3RT
Dr selection of OSPF configuration for Huawei devices
做微服务研发工程师的一年来的总结
What kind of experience is it to realize real-time collaboration in jupyter
Attention SLAM:一种从人类注意中学习的视觉单目SLAM
Learn to use code to generate beautiful interface documents!!!
[software reverse automation] complete collection of reverse tools
[yolov5 6.0 | 6.1 deploy tensorrt to torch serve] environment construction | model transformation | engine model deployment (detailed packet file writing method)
[force buckle]41 Missing first positive number
Model-Free Control
批量获取中国所有行政区域经边界纬度坐标(到县区级别)
【软件逆向-自动化】逆向工具大全
Slow database query optimization