You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
const int N = 1e5 + 10;
|
|
|
|
int primes[N], cnt; // primes[]存储所有素数
|
|
bool st[N]; // st[x]存储x是否被筛掉
|
|
|
|
int factor[N]; // 存储每一个数的质因子个数
|
|
|
|
void get_primes(int n) {
|
|
memset(st, 0, sizeof st);
|
|
for (int i = 2; i <= n; i++) {
|
|
if (!st[i]) {
|
|
primes[cnt++] = i;
|
|
factor[i] = 1; // 质数的质因子个数是1
|
|
}
|
|
for (int j = 0; primes[j] * i <= n; j++) {
|
|
st[primes[j] * i] = true; // 标识primes[j] * i是个合数
|
|
factor[primes[j] * i] = factor[i] + 1; // t=primes[j]*i,那么t的质因子个数=i的质因子个数+1
|
|
if (i % primes[j] == 0) break; // 只被最小的质数因子筛掉
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int n, m;
|
|
cin >> n >> m;
|
|
|
|
get_primes(m);
|
|
|
|
int res = 0;
|
|
for (int i = n; i <= m; i++) {
|
|
res = max(res, factor[i]);
|
|
// printf("The count of prime factor(s) of %d is: %d\n", i, factor[i]);
|
|
}
|
|
cout << res << endl;
|
|
return 0;
|
|
} |