LibreOJ #6165. 一道水题

时间:2024-06-04 16:37:56

二次联通门 : LibreOJ #6165. 一道水题

/*
LibreOJ #6165. 一道水题 欧拉线性筛
其实题意就是求区间[1, n]所有数的最小公倍数 那么答案就是所有质因子最大幂次的乘积 水题开心。。
*/
#include <cstdio>
#include <iostream> #define Max 100000290 int prime[Max], Count;
bool is_prime[Max]; long long Euler_Line_Sieve (const int &N)
{
#define Mod 100000007
register int i, j; is_prime[] = true;
long long res, Answer = ;
for (i = ; i <= N; ++ i)
{
if (is_prime[i] == false)
{
prime[++ Count] = i;
for (res = i; res * (long long) i <= N; res *= i);
Answer = (Answer * res) % Mod;
}
for (j = ; j <= Count && i * prime[j] <= N; ++ j)
{
is_prime[i * prime[j]] = true;
if (i % prime[j] == )
break;
}
}
#undef Mod
return Answer;
}
int Main ()
{
int N;
scanf ("%d", &N);
long long Answer = Euler_Line_Sieve (N); printf ("%lld", Answer);
return ;
} int ZlycerQan = Main ();
int main (int argc, char *argv[]) {;}