思路:

\[能想到平方是比较特殊的,因为x*x一定是x的倍数也就是说\sqrt[2]{x*x} = {x}
\]
\[所以需要考虑平法之间的数手模一下样例可以发现 [x^2 ,(x+1)^2)之间是x倍数的有x^2
\]
\[x*(x+1), x*(x+2)这三个,所以可以知道平方之间有三个,只要讨论一下出来整个区间边界还有多少个
\]

这里可以用一个前缀和去优化就只用考虑右边界,右边界和上面三个讨论

\[[x^2 ,(x+1) * x) \quad 答案+1
\]
\[[(x+1) * x ,(x+2) * x) \quad 答案+1
\]
\[[(x+2) * x ,(x+1)^2) \quad 答案+1
\]
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<t<<endl; using namespace std;
const int N = 1e6 + 10;
int t; ll get(ll x)
{
ll res = 0, m = sqrt(x);
res += (m - 1) * 3;
if(x >= m * m) res ++;
if(x >= (m + 1) * m) res ++;
if(x >= (m + 2) * m) res ++;
return res;
} void solve()
{
ll l, r, ans = 0; cin >> l >> r; cout << get(r) - get(l - 1) << endl;
} int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
cin >> t;
// while(t --)
// solve();
debug(t)
return 0;
}

B. Ela's Fitness and the Luxury Number的更多相关文章

  1. [题解] Codeforces Dytechlab Cup 2022 1737 A B C D E 题解

    傻*Dytechlab还我rating!(不过目前rating还没加上去,据说E是偷的说不定要unrated) 实在没预料到会打成这样... 求点赞 点我看题 A. Ela Sorting Books ...

  2. Dytechlab Cup 2022 (A - C)

    Dytechlab Cup 2022 (A - C) A - Ela Sorting Books 分析:贪心,将字符串每一位都存在map里,从前往后尽量让每一个\(n / k\)的段\(mex\)值尽 ...

  3. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  4. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  5. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  6. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  7. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  8. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  9. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  10. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

随机推荐

  1. ABP vNext系列文章01---模块化

    一.模块化应用  1.继承AbpModule 每个模块都应该定义一个模块类.定义模块类的最简单方法是创建一个派生自AbpModule的类,如下所示:  2.配置依赖注入和其他模块---ConfigSe ...

  2. pycharm的docstring多了一行type

    注释中多了一行:type 设置为Epytext PyCharm 2020.3.5 (Community Edition) def test(param1,param2,param3): "& ...

  3. Unity字体和画面花屏处理

    字体花屏和相机渲染花屏,这两者的表现有明显的差异. 字体花屏 字体花屏是持续性的,直到组件被刷新,或字体图集被刷新.目前在我们项目中当游戏启动时,就会填充游戏用到的所有字符到贴图中,所以并没有遇到此问 ...

  4. 小白学k8s(11)-k8s中Secret理解

    理解Secret 什么是Secret Secret的类型 Opaque Secret Opaque Secret的使用 将Secret挂载到Volume中 挂载的Secret会被自动更新 将Secre ...

  5. 【2】Visual Studio 2017同时配置OpenCV2.4 以及OpenCV4.3

    相关文章: [1]windows下安装OpenCV(4.3)+VS2017安装+opencv_contrib4.3.0配置 [2]Visual Studio 2017同时配置OpenCV2.4 以及O ...

  6. C/C++ 类与构造析构等知识

    简单定义类 #include <iostream> #include <string> using namespace std; class Student { public: ...

  7. C/C++ Npcap包实现数据嗅探

    npcap 是Nmap自带的一个数据包处理工具,Nmap底层就是使用这个包进行收发包的,该库,是可以进行二次开发的,不过使用C语言开发费劲,在进行渗透任务时,还是使用Python构建数据包高效,这东西 ...

  8. 苹果iOS的应用移除主屏幕及恢复找回

    昨天刷到一个苹果iOS系统更换微信图标的,然后就添加了一个,发现那个记录通知数字问题,想恢复回来,所以就有了此文. https://www.cnblogs.com/lzhdim/p/17909867. ...

  9. 基于 Gurobi 的纸浆运载船顺序装卸决策建模求解|Gurobi优化应用

    Pulp-Carrier-Loading-Optimization-with-Gurobi 基于 Gurobi 的纸浆运载船顺序装卸决策建模求解.中山大学智能工程学院<运筹学>课程期末建模 ...

  10. Java21 + SpringBoot3集成七牛云对象存储OSS,实现文件上传

    目录 前言 实现步骤 引入maven依赖 修改配置文件 创建七牛云配置类 创建文件操作服务类 创建文件操作控制器 前端实现 运行效果 总结 前言 近日心血来潮想做一个开源项目,目标是做一款可以适配多端 ...