题目
((lcm_{i=1}^ni)mod 10^8+7,nleq 10^8)
分析
考虑对于某个质数(p),在(n)范围内做出的最大贡献为(p^k(p^kleq n)),
线性筛出所有质数求它的最大指数幂再相乘即可
代码
#include <cstdio>
#define rr register
using namespace std;
const int N = 100000007;
int prime[N], n, ans, Cnt;
bool v[N];
signed main() {
scanf("%d", &n), ans = 1;
for (rr int i = 2; i <= n; ++i) {
if (!v[i]) {
prime[++Cnt] = i;
rr int t = n;
while (t >= i) t /= i, ans = 1ll * ans * i % N;
}
for (rr int j = 1; j <= Cnt && prime[j] <= n / i; ++j) {
v[i * prime[j]] = 1;
if (i % prime[j] == 0)
break;
}
}
return !printf("%d", ans);
}