首页 > 因子区间
头像 retyrn
发表于 2024-05-26 21:27:33
D 因子区间 首先,1e5之内的数最多拥有128个因子,所以可以从 1 ~ 128 枚举因子个数,分别计算。 对于每个因子数记录下来该因子数对应的原数组中每个数的下标,二分找到范围内的个数后利用组合数进行计算。时间复杂度 在这之前,可以 预处理1e5内每个数的因子个数. int n, q; vo 展开全文
头像 玉殒汝成
发表于 2024-05-26 22:42:32
``` java [] import java.io.*; import java.util.*; public class Main { static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStream 展开全文
头像 玄骨
发表于 2025-11-01 13:59:54
#include<bits/stdc++.h> using namespace std; using ll = long long; int find(int x){//计算有多少因子,题解是直接算 int count=0; for(int i=1;i*i<=x;i 展开全文
头像 陆希琳709317
发表于 2025-11-06 19:47:57
思路首先看到题目,不难想到先将因子数量求出来,求因子数量使用了 线性筛 。对数字进行唯一分解,则该数字的因子数量为 随后问题转化为,给一个长度为 的数组,求出区间内使得的数对个数,我们使用 莫队 求解。代码 #include <bits/stdc++.h> std::vector< 展开全文
头像 还会喜欢上刻晴吗
发表于 2025-11-01 18:53:28
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define inf LLONG_MAX const int mod=1e9+7; void 展开全文
头像 Kato_Shoko
发表于 2025-11-01 22:27:49
注意到因子个数比较少,所以直接暴力的来使用前缀和来查询区间里面有多少个相同的因子,然后组合数学一下,得到共有多少匹配就行了。 #include <bits/stdc++.h> #define il inline using namespace std; using ll = long 展开全文
头像 Nimsolax
发表于 2025-11-01 10:07:20
#include <iostream> using namespace std; #include<vector> #include<map> #include<cmath> int main() { int n,q; cin> 展开全文
头像 wsjdoudou
发表于 2025-11-02 21:06:08
2025.11.1日每日一题 标签:前缀和/二分法 语法: 注意开 long long 的答案,乘法要记得乘以 1LL 题目里提到因子,我们要把输入的 a 数列处理成相对应的因子: 大致有两种算法 第一种是暴力遍历 for(int j=1;j<N;j++){ for(int 展开全文

等你来战

查看全部