完全平方数 (打表)
https://ac.nowcoder.com/acm/contest/5203/C
打表例题。
#include <iostream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <string>
#include <cstdio>
#include <set>
#include <cstdio>
#include <fstream>
#include <deque>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <iomanip>
#define SIS std::ios::sync_with_stdio(false)
#define ll long long
#define INF 0x3f3f3f3f
const int mod = 1e9 + 7;
const double esp = 1e-5;
const double PI = 3.141592653589793238462643383279;
using namespace std;
const int N = 1e7 + 5;
const int maxn = 1 << 20;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; while (b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
/*void chafen(int l, int r, int k) {//差分函数p[l] += k;p[r + 1] -= k;
}*/
/*************************************************************/
ll s[N];
int main() {ll t = 0;for (int i = 0; i * i <= 1000000000; i++)s[++t] = i * i;int n;cin >> n;while (n--) {ll l, r;cin >> l >> r;int pos1 = upper_bound(s + 1, s + 1 + t, r) - s;int pos2 = lower_bound(s + 1, s + 1 + t, l) - s;int ans = pos1 - pos2;cout << ans << endl;}return 0;
}
完全平方数 (打表)相关推荐
- 完全平方数(打表+二分)
链接:https://ac.nowcoder.com/acm/contest/5203/C 来源:牛客网 完全平方数 题目描述 多次查询[l,r][l,r][l,r]范围内的完全平方数个数 定义整数x ...
- 完全平方数的判定及整数平方根的快速求解
原帖:http://hi.baidu.com/atyuwen/blog/item/206369fdae6d221e09244da9.html 在上个星期的"有道难题"网络预赛中,某 ...
- 【题解报告】Leecode367. 有效的完全平方数——Leecode每日一题系列
今天是坚持每日一题打卡的第九天 题目链接:https://leetcode-cn.com/problems/valid-perfect-square/ 题解汇总:https://zhanglong.b ...
- 用完全平方数填满指定区域(洛谷P2666题题解,Java语言描述)
题目要求 P2666题目链接 分析 按照题目要求,无非是用四个完全平方数填满指定区域罢了. N就是多大区域而已啦,块数实际上是4块,也就是4个完全平方数. 这样看来这题不难,但我们打个表也是极好的. ...
- [2021CCPC威海热身赛] Number Theory (打表 推公式)
题意 求 ∑ k = 1 n ∑ i ∣ k ∑ j ∣ i λ ( i ) λ ( j ) \sum_{k = 1}^{n}\sum_{i \mid k} \sum_{j \mid i} \lamb ...
- 哈希表(一)(散列)分离链接法实现
编译环境:vs2015 实现100以内完全平方数的哈希表建立,当然更多数也是可以的--基本是例题难度,写了好大一天. 定义结构体: 主要实现函数: // ConsoleApplication5.cpp ...
- python计算复数的平方根将产生_Python_每日习题_0003_完全平方数
# 题目 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? # 程序分析 因为168对于指数爆炸来说实在太小了,所以可以直接省略数学分析,用最朴素的方法来获取 ...
- excel设置打印区域_仅在没有打印区域的情况下打印Excel表
excel设置打印区域 Today, we'll look at a time-saving Table trick that you might not know about. See how to ...
- 279. 完全平方数(java)
279. 完全平方数 题目描述 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, -)使得它们的和等于 n.你需要让组成和的完全平方数的个数最少. 示例 1: 输入: n = 12 ...
最新文章
- Reconstructing complex regions of genomes using long-read sequencingtechnology
- Oracle数据库实例的创建、删除、修改
- 两个sql交集_如何使用性能分析工具定位SQL执行慢的原因?
- java在frame怎么计时_java – 退出jframe时的Swing stop计时器
- 15 个第三方Web 表单资源
- JVM stack与Heap的区别
- 在 macOS 中如何使用「预览」批量调整图片大小?
- Deep Learning for Joint Channel Estimation and Feedback in Massive MIMO Systems
- 数据结构课程设计(学生选课管理系统)链表实现
- ai的预览模式切换_ai预览快捷键是什么,Adobe Illustrator预览快捷键是什么?
- Python实现多张图片合成一张马赛克图片
- 贪心科技机器学习训练营(六)
- echarts制作两个纵轴的折线图
- 81章 老子1章到_三曜道长解读道德经: 信言不美 第81章
- 漏洞系列一一看我一招征服漏洞SSRF
- [转] 蝴蝶效应,青蛙现象,鳄鱼法则,鲇鱼效应,羊群效应,刺猬法则,手表定律,破窗理论,二八定律,木桶理论,马太效应,这些你都明白吗?...
- 【编译原理】Python实现对一个英文文本的词频统计
- 关于通信方面的总结(通信协议、通信端口)
- 心脏出血漏洞(CVE-2014-0160)
- 2017年蓝桥杯C组真题及解析