思路:

\[能想到平方是比较特殊的,因为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. Typora 1.6.7永久激活

    介绍Typora介绍 具体看上面的我就不多介绍了 接下来我们开始教程 需要的文件 Typora安装包 破解补丁包 安装包下载 破解补丁下载 接下来我们全部下载后获得一个安装包一个补丁 安装包直接安装就 ...

  2. 安装Visual Studio的详细流程

      本文介绍Visual Studio 2022软件Community(社区版)的下载.安装.运行与使用方法.   首先需要提一句,本文介绍的是Visual Studio 2022软件的下载:而其它版 ...

  3. 使用CSS3实现鼠标移到图片上图片放大

    转自 http://www.webkaka.com/tutorial/html/2017/072731/ 在现在的网页设计中,鼠标移到图片上图片放大的效果常常被用到,这个效果多应用于文章列表里.我一开 ...

  4. Java中YYYY-MM-dd在跨年时出现的bug

    先看一张图: Bug的产生原因: 日期格式化时候,把 yyyy-MM-dd 写成了 YYYY-MM-dd Bug分析: 当时间是2019-08-31时, public class DateTest { ...

  5. 从零开始教你手动搭建幻兽帕鲁私服( CentOS 版)

    哈喽大家好,我是咸鱼. 想必上网冲浪的小伙伴最近都被<幻兽帕鲁>这款游戏刷屏了. (文中图片均来自网络,侵删) 幻兽帕鲁是 Pocketpair 打造的一款开放世界的生存建造游戏.在游戏中 ...

  6. 深入浅出Java多线程(八):volatile

    引言 大家好,我是你们的老伙计秀才!今天带来的是[深入浅出Java多线程]系列的第八篇内容:volatile.大家觉得有用请点赞,喜欢请关注!秀才在此谢过大家了!!! 在当今的软件开发领域,多线程编程 ...

  7. NC20477 [ZJOI2008]树的统计COUNT

    题目链接 题目 题目描述 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w. 我们将以下面的形式来要求你对这棵树完成 一些操作: I. CHANGE u t : 把结点u的权值改为t II ...

  8. elasticsearch should实现or功能,设置minimum_should_match

    elasticsearch实现传统数据库中的or功能,需要使用bool下面的should关键字,对于A or B的情况,应该至少返回A和B中的一个,但是如下语句,不仅返回A和B中的至少一个,也返回了没 ...

  9. oracle中使用自定义函数解析指定分隔符的字符串

    1.创建字符串表类型 create type tab_varchar is table of varchar2(2000); 2.创建管道函数 create or replace function g ...

  10. Redis服务端事件处理流程分析

    一.事件处理 1.1 什么是事件 Redis 为什么运行得比较快? 原因之一就是它的服务端处理程序用了事件驱动的处理方式. 那什么叫事件处理?就是把处理程序当成一个一个的事件处理.比如我前面文章:服务 ...