[luogu p7464] [CERC2018] The Silence of the Lamps
洛谷 P7464 [CERC2018] The Silence of the Lamps
P7464 [CERC2018] The Silence of the Lamps - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
给定一个数
为什么不 % 1e9 + 7
发现本题中的三元组合法性满足包含关系,举个例子:
因此首先考虑将询问离线下来,对每个
复杂度无法承受。考虑逆向思维,暴力枚举
然后这个题就做完了。
不会求,感觉大概
/*
* @Author: crab-in-the-northeast
* @Date: 2022-05-04 12:34:28
* @Last Modified by: crab-in-the-northeast
* @Last Modified time: 2022-05-04 12:46:55
*/
#include <iostream>
#include <cstdio>
#include <cmath>
inline int read() {
int x = 0;
bool flag = true;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
flag = false;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
if(flag) return x;
return ~(x - 1);
}
const int maxn = 1e6 + 5;
int a[maxn];
int main() {
int T = read();
for (int i = 1; i < cbrt(maxn); ++i)
for (int j = i + 1; j <= maxn / i; ++j)
for (int k = j + 1; k <= maxn / i / j; ++k)
++a[i * j * k];
for (int i = 2; i <= maxn; ++i)
a[i] += a[i - 1];
while (T--) {
int x = read();
printf("%d\n", a[x]);
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现