思路:

\[能想到平方是比较特殊的,因为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. 深度学习应用篇-元学习[15]:基于度量的元学习:SNAIL、RN、PN、MN

    深度学习应用篇-元学习[15]:基于度量的元学习:SNAIL.RN.PN.MN 1.Simple Neural Attentive Learner(SNAIL) 元学习可以被定义为一种序列到序列的问题 ...

  2. C++ Qt开发:运用QJSON模块解析数据

    Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍如何运用QJs ...

  3. Java开发学习(四十七)----MyBatisPlus删除语句之多记录操作

    1.多记录操作 先来看下问题: 之前添加了很多商品到购物车,过了几天发现这些东西又不想要了,该怎么办呢? 很简单删除掉,但是一个个删除的话还是比较慢和费事的,所以一般会给用户一个批量操作,也就是前面有 ...

  4. 火山引擎ByteHouse:如何为OLAP设计高性能向量检索能力?

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 背景 随着LLM技术应用及落地,数据库需要提高向量分析以及AI支持能力,向量数据库及向量检索等能力"异军 ...

  5. Linux zip常用命令

    1.将当前目录下的所有文件和文件夹全部压缩成myfile.zip内联代码块文件zip -r myfile.zip ./*-r表示递归压缩子目录下所有文件. 2.unzip把myfile.zip文件解压 ...

  6. 树莓派安装Ubuntu系统

    树莓派版本: Raspberry Pi 4B 操作系统 : Ubuntu Server 20.04_x64 树莓派官网: https://www.raspberrypi.org/ ubuntu官网:  ...

  7. 写好C#代码的技巧

    写好C#代码的技巧 编者导语 本文来自https://www.pluralsight.com,作者Afzaal Ahmad Zeeshan. 原文包含以下三篇文章: <编写更好的C#代码简介&g ...

  8. lsattr命令

    lsattr命令 lsattr命令用于显示文件的属性. 语法 lsattr [-RVadlv] [file | folder] 参数 -a: 显示所有文件和目录,包括以.为名称开头字符的额外内建,即现 ...

  9. Oracle11gr2新增APPEND_VALUES提示

    在11.2中,Oracle新增了APPEND_VALUES提示,使得INSERT INTO VALUES语句也可以使用直接路径插入. 例子很简单: SQL> SELECT * FROM V$VE ...

  10. 这样优化,0.059s 启动一个SpringBoot项目

    https://mp.weixin.qq.com/s/2_tQO7Z6GfmC6y73jc6ITQ