当前位置:网站首页>[牛客] 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 ;
}
边栏推荐
- [software reverse - solve flag] memory acquisition, inverse transformation operation, linear transformation, constraint solving
- 【批處理DOS-CMD命令-匯總和小結】-字符串搜索、查找、篩選命令(find、findstr),Find和findstr的區別和辨析
- ActiveReportsJS 3.1中文版|||ActiveReportsJS 3.1英文版
- Data analysis course notes (III) array shape and calculation, numpy storage / reading data, indexing, slicing and splicing
- 【JokerのZYNQ7020】AXI_ EMC。
- ZYNQ移植uCOSIII
- If the college entrance examination goes well, I'm already graying out at the construction site at the moment
- Common shortcuts to idea
- 第六篇,STM32脉冲宽度调制(PWM)编程
- Advanced learning of MySQL -- Fundamentals -- concurrency of transactions
猜你喜欢

Attention slam: a visual monocular slam that learns from human attention

学习光线跟踪一样的自3D表征Ego3RT

Js+svg love diffusion animation JS special effects

Chapter II proxy and cookies of urllib Library

Data analysis course notes (V) common statistical methods, data and spelling, index and composite index
![[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr](/img/4a/0dcc28f76ce99982f930c21d0d76c3.png)
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr

Equals() and hashcode()

Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang

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

Dell笔记本周期性闪屏故障
随机推荐
Leetcode(547)——省份数量
Service asynchronous communication
深度学习简史(一)
Stm32f407 ------- SPI communication
通过串口实现printf函数,中断实现串口数据接收
在jupyter中实现实时协同是一种什么体验
build. How to configure the dependent version number in the gradle file
Meet the level 3 requirements of ISO 2.0 with the level B construction standard of computer room | hybrid cloud infrastructure
[user defined type] structure, union, enumeration
[software reverse automation] complete collection of reverse tools
fastDFS数据迁移操作记录
Part IV: STM32 interrupt control programming
深度学习之数据处理
Let's talk about 15 data source websites I often use
If the college entrance examination goes well, I'm already graying out at the construction site at the moment
Part 7: STM32 serial communication programming
Trace tool for MySQL further implementation plan
英雄联盟|王者|穿越火线 bgm AI配乐大赛分享
The printf function is realized through the serial port, and the serial port data reception is realized by interrupt
Data analysis course notes (III) array shape and calculation, numpy storage / reading data, indexing, slicing and splicing