当前位置:网站首页>[Niuke] b-complete square
[Niuke] b-complete square
2022-07-07 01:05:00 【*DDL_ GzmBlog】
Preface
Use stl Two points , The best subscript is from 0 Let's start
t a g : tag : tag: Two points
mathematics
The question :
Ideas :
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
Again because l , r ≤ 1 0 9 l,r\le10^9 l,r≤109 So we can preprocess out x \sqrt x x Array
Finally, determine the square interval by bisection , The size of the square interval is the answer
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 ;
}
边栏推荐
- Learning notes 5: ram and ROM
- In rails, when the resource creation operation fails and render: new is called, why must the URL be changed to the index URL of the resource?
- Learn to use code to generate beautiful interface documents!!!
- Configuring the stub area of OSPF for Huawei devices
- from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or direc
- 深度学习之线性代数
- 批量获取中国所有行政区域经边界纬度坐标(到县区级别)
- Configuring OSPF basic functions for Huawei devices
- Service asynchronous communication
- mongodb客户端操作(MongoRepository)
猜你喜欢
[software reverse - solve flag] memory acquisition, inverse transformation operation, linear transformation, constraint solving
Part IV: STM32 interrupt control programming
Dell笔记本周期性闪屏故障
Zynq transplant ucosiii
Part V: STM32 system timer and general timer programming
学习使用代码生成美观的接口文档!!!
Configuring the stub area of OSPF for Huawei devices
Deeply explore the compilation and pile insertion technology (IV. ASM exploration)
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
5种不同的代码相似性检测,以及代码相似性检测的发展趋势
随机推荐
接口(接口相关含义,区别抽象类,接口回调)
城联优品入股浩柏国际进军国际资本市场,已完成第一步
动态规划思想《从入门到放弃》
Leetcode(547)——省份数量
Cause of handler memory leak
随时随地查看远程试验数据与记录——IPEhub2与IPEmotion APP
筑梦数字时代,城链科技战略峰会西安站顺利落幕
Part V: STM32 system timer and general timer programming
[user defined type] structure, union, enumeration
腾讯云 WebShell 体验
Js+svg love diffusion animation JS special effects
[牛客] [NOIP2015]跳石头
Fastdfs data migration operation record
Advantages and disadvantages of code cloning
深度学习框架TF安装
Levels - UE5中的暴雨效果
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
Leetcode (547) - number of provinces
Linear algebra of deep learning
Distributed cache