思路:

\[能想到平方是比较特殊的,因为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. 2.6 Windows驱动开发:使用IO与DPC定时器

    本章将继续探索驱动开发中的基础部分,定时器在内核中同样很常用,在内核中定时器可以使用两种,即IO定时器,以及DPC定时器,一般来说IO定时器是DDK中提供的一种,该定时器可以为间隔为N秒做定时,但如果 ...

  2. LyScript 计算片段Hash并写出Excel

    本案例将学习运用LyScript计算特定程序中特定某些片段的Hash特征值,并通过xlsxwriter这个第三方模块将计算到的hash值存储成一个excel表格,本例中的知识点可以说已经具备了简单的表 ...

  3. Mac 下安装 mysqlclient

    brew install mysql export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/ ...

  4. npm旧淘宝镜像过期,更换新淘宝镜像

    1. 清空缓存 npm cache clean --force 2.设置新淘宝镜像 npm config set registry https://registry.npmmirror.com/ 3. ...

  5. 架构设计脱胎换骨!英特尔酷睿Ultra深度解析

    英特尔正式发布了第一代酷睿Ultra处理器平台,也就是首个基于Intel 4制程工艺(7nm)打造的移动级处理器平台,其核心代号为Meteor Lake,产品系列贴标设计也采用了全新方案. 同时在命名 ...

  6. P9474 [yLOI2022] 长安幻世绘题解

    题目链接: [yLOI2022] 长安幻世绘 比较不错的综合题.考虑下处理极差的绝对值我们应该怎么做,很显然排序是有必要的,我们需要带着下标排序. 考虑几个核心点: 1.假如没有其他限制考虑极差与序列 ...

  7. 从TF-IDF 到BM25, BM25+,一文彻底理解文本相关度

    相关性描述的是⼀个⽂档和查询语句匹配的程度.我们从搜索引擎召回时,肯定希望召回相关性高的数据,那么如何来量化相关度呢. 首先,我们定义,一个文档doc,由多个词语 term 组成. 最早,通过最简单的 ...

  8. .NET 云原生架构师训练营(模块二 基础巩固 MVC终结点)--学习笔记

    2.3.4 Web API -- MVC终结点 MVC与MVVM 模型绑定 自定义模型绑定器 模型验证 返回数据处理 MVC与MVVM MVC ASP.NET Core MVC 概述:https:// ...

  9. 《ASP.NET Core 与 RESTful API 开发实战》-- (第9章)-- 读书笔记(下)

    集成测试 集成测试能够确保应用程序的组件正常工作,包括应用程序支持的基础结构,如数据库和文件系统等 进行集成测试时,应为项目添加 Microsoft.AspNetCore.MvcTesting 包 它 ...

  10. C++ map自定义比较函数遵守严格弱序

    C++ map自定义比较函数遵守严格弱序 问题背景及定位 背景:这个问题是在将tablesaw(一个Java的数据处理项目)迁移到C++时出现的. 问题位置:SplitOn()函数,在数据流水线中的a ...