当前位置:网站首页>[牛客] 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 ;
}
边栏推荐
- Basic information of mujoco
- 再聊聊我常用的15个数据源网站
- 省市区三级坐标边界数据csv转JSON
- Periodic flash screen failure of Dell notebook
- Trace tool for MySQL further implementation plan
- Service asynchronous communication
- Telerik UI 2022 R2 SP1 Retail-Not Crack
- Hero League | King | cross the line of fire BGM AI score competition sharing
- 随时随地查看远程试验数据与记录——IPEhub2与IPEmotion APP
- Let's talk about 15 data source websites I often use
猜你喜欢
Set (generic & list & Set & custom sort)
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
集合(泛型 & List & Set & 自定义排序)
If the college entrance examination goes well, I'm already graying out at the construction site at the moment
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr
Telerik UI 2022 R2 SP1 Retail-Not Crack
Deep understanding of distributed cache design
Stm32f407 ------- DAC digital to analog conversion
筑梦数字时代,城链科技战略峰会西安站顺利落幕
Distributed cache
随机推荐
【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
Installation and testing of pyflink
Configuring the stub area of OSPF for Huawei devices
Telerik UI 2022 R2 SP1 Retail-Not Crack
【批处理DOS-CMD命令-汇总和小结】-查看或修改文件属性(ATTRIB),查看、修改文件关联类型(assoc、ftype)
迈动互联中标北京人寿保险,助推客户提升品牌价值
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr
建立自己的网站(17)
[Niuke classic question 01] bit operation
Meet the level 3 requirements of ISO 2.0 with the level B construction standard of computer room | hybrid cloud infrastructure
Matlab learning notes
Slam d'attention: un slam visuel monoculaire appris de l'attention humaine
[force buckle]41 Missing first positive number
Dr selection of OSPF configuration for Huawei devices
Deeply explore the compilation and pile insertion technology (IV. ASM exploration)
Alexnet experiment encounters: loss Nan, train ACC 0.100, test ACC 0.100
Web project com mysql. cj. jdbc. Driver and com mysql. jdbc. Driver differences
代码克隆的优缺点
第六篇,STM32脉冲宽度调制(PWM)编程
How to get started and improve test development?