Files
python/TangDou/AcWing_TiGao/T5/YueShuGeShu/1294_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

42 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = 1e9 + 7;
// 60 ms
// 欧拉筛
const int N = 1e6 + 10;
int primes[N], cnt; // primes[]存储所有素数
bool st[N]; // st[x]存储x是否被筛掉
void get_primes(int n) {
memset(st, 0, sizeof st);
cnt = 0;
for (int i = 2; i <= n; i++) {
if (!st[i]) primes[cnt++] = i;
for (int j = 0; primes[j] * i <= n; j++) {
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}
signed main() {
int n;
cin >> n;
// 步骤1:筛质数
get_primes(n);
// 步骤2:阶乘质因子分解
int res = 1;
for (int i = 0; i < cnt; i++) {
int p = primes[i];
int s = 0;
for (int j = n; j; j /= p) s += j / p; // 应除尽除
// 步骤3:约数个数公式.因为通过公式推导我们知道,不是n!,而是(n!)^2,所以,是(2*s+1)做为累乘因子
res = res * (2 * s + 1) % MOD;
}
cout << res << endl;
}