二次联通门 : 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[1] = true; long long res, Answer = 1; for (i = 2; 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 = 1; j <= Count && i * prime[j] <= N; ++ j) { is_prime[i * prime[j]] = true; if (i % prime[j] == 0) break; } } #undef Mod return Answer; } int Main () { int N; scanf ("%d", &N); long long Answer = Euler_Line_Sieve (N); printf ("%lld", Answer); return 0; } int ZlycerQan = Main (); int main (int argc, char *argv[]) {;}