for (int i = 2; i <= n; i++) { if (!vis[i]) primes.push_back(i); for (int p : primes) { if (p > n / i) break; vis[i * p] = true; if (i % p == 0) break; } }
vector<pair<i64, int>> factor(i64 n) { vector<pair<i64, int>> fac; for (i64 p = 2; p <= n / p; p++) if (n % p == 0) { int c = 0; while (n % p == 0) { n /= p; c++; } fac.push_back({p, c}); } if (n > 1) fac.push_back({n, 1}); return fac; }
vector<i64> divisors(i64 n){ vector<i64> d; for (i64 x = 1; x <= n / x; x++) if (n % x == 0) { d.push_back(x); if (x != n / x) d.push_back(n / x); } sort(d.begin(), d.end()); return d; }
i64 mulM(i64 a, i64 b, i64 mod){ return (i128)a * b % mod; } i64 qpow(i64 a, i64 b, i64 mod){ i64 ans = 1 % mod; a %= mod; if (a < 0) a += mod; for (; b; b >>= 1, a = mulM(a, a, mod)) if (b & 1) ans = mulM(ans, a, mod); return ans; }
/* Fufffh */ #include<bits/stdc++.h> usingnamespace std; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t;
intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<int> primes; vector<bool> vis(n + 1); for (int i = 2; i <= n; i++) { if (!vis[i]) primes.push_back(i); for (int p : primes) { if (p > n / i) break; vis[i * p] = true; if (i % p == 0) break; } } while (q--) { int k; cin >> k; cout << primes[k - 1] << '\n'; } return0; }
/* Fufffh */ #include<bits/stdc++.h> usingnamespace std; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t;
intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); i64 n; cin >> n; for (i64 p = 2; p <= n / p; p++) if (n % p == 0) { cout << n / p << '\n'; break; } return0; }
/* Fufffh */ #include<bits/stdc++.h> usingnamespace std; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t;
i64 gcd(i64 a, i64 b){ return b ? gcd(b, a % b) : a; } i64 lcm(i64 a, i64 b){ return a / gcd(a, b) * b; }
intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; i64 ans = 1; while (n--) { i64 x; cin >> x; ans = lcm(ans, x); } cout << ans << '\n'; return0; }
/* Fufffh */ #include<bits/stdc++.h> usingnamespace std; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t; constint N = 1e6;
intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); vector<bool> prime(N + 1, true); prime[0] = prime[1] = false; for (int i = 2; i <= N / i; i++) if (prime[i]) for (int j = i * i; j <= N; j += i) prime[j] = false; int n; cin >> n; while (n--) { i64 x, r; cin >> x; r = sqrtl((longdouble)x); while ((r + 1) * (r + 1) <= x) r++; while (r * r > x) r--; cout << (r * r == x && prime[r] ? "YES\n" : "NO\n"); } return0; }
/* Fufffh */ #include<bits/stdc++.h> usingnamespace std; using i32 = int32_t; using i64 = int64_t; using i128 = __int128_t; using u32 = uint32_t; using u64 = uint64_t; using u128 = __uint128_t; constint MOD = 1e9 + 7;
intaddM(int a, int b, int mod = MOD){ return (a += b) >= mod ? a - mod : a; } intsubM(int a, int b, int mod = MOD){ return (a -= b) < 0 ? a + mod : a; } intmulM(int a, int b, int mod = MOD){ return (i64)a * b % mod; } intqpow(int a, i64 b, int mod = MOD){ int ans = 1; for (; b; b >>= 1, a = mulM(a, a, mod)) if (b & 1) ans = mulM(ans, a, mod); return ans; }
intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); i64 n; cin >> n; int p9 = qpow(9, n), ans = subM(qpow(10, n), p9); ans = addM(subM(ans, p9), qpow(8, n)); cout << ans << '\n'; return0; }