結果
問題 | No.2902 ZERO!! |
ユーザー | Today03 |
提出日時 | 2024-09-27 21:57:17 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 341 ms / 2,000 ms |
コード長 | 5,094 bytes |
コンパイル時間 | 3,812 ms |
コンパイル使用メモリ | 265,864 KB |
実行使用メモリ | 128,948 KB |
最終ジャッジ日時 | 2024-09-27 21:57:32 |
合計ジャッジ時間 | 9,229 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 339 ms
128,948 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 64 ms
29,900 KB |
testcase_05 | AC | 142 ms
62,728 KB |
testcase_06 | AC | 341 ms
122,116 KB |
testcase_07 | AC | 84 ms
36,804 KB |
testcase_08 | AC | 293 ms
113,348 KB |
testcase_09 | AC | 288 ms
110,596 KB |
testcase_10 | AC | 208 ms
82,724 KB |
testcase_11 | AC | 160 ms
67,244 KB |
testcase_12 | AC | 20 ms
10,240 KB |
testcase_13 | AC | 291 ms
112,756 KB |
testcase_14 | AC | 221 ms
86,528 KB |
testcase_15 | AC | 253 ms
98,092 KB |
testcase_16 | AC | 133 ms
57,336 KB |
testcase_17 | AC | 288 ms
109,536 KB |
testcase_18 | AC | 273 ms
104,060 KB |
testcase_19 | AC | 241 ms
92,864 KB |
testcase_20 | AC | 205 ms
78,532 KB |
testcase_21 | AC | 216 ms
84,972 KB |
testcase_22 | AC | 96 ms
42,772 KB |
testcase_23 | AC | 143 ms
60,528 KB |
testcase_24 | AC | 3 ms
6,944 KB |
testcase_25 | AC | 3 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 3 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; /* 考察 b=N!のとき、e_b=1 b=(N!-1)のとき、e_b=0かな? N!の素因数分解ができるのか だから、e_bが1になるのはいくつ、e_bが2になるのはいくつ。。。みたいにやることを考える。 e_b=1以上となるのは、全ての素因数について指数/1以下 e_b=2以上となるのは、全ての素因数について指数/2以下 e_b=i以上となるのは、全ての素因数について指数/i以下 */ template <ll MOD> struct ModInt { ll value; ModInt(ll x = 0) { if (x >= 0) { value = x % MOD; } else { value = MOD - (-x) % MOD; } } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt &operator+=(const ModInt &other) { value += other.value; if (value >= MOD) value -= MOD; return *this; } ModInt &operator-=(const ModInt &other) { value += MOD - other.value; if (value >= MOD) value -= MOD; return *this; } ModInt &operator*=(const ModInt other) { value = value * other.value % MOD; return *this; } ModInt &operator/=(ModInt other) { (*this) *= other.inv(); return *this; } ModInt operator+(const ModInt &other) const { return ModInt(*this) += other; } ModInt operator-(const ModInt &other) const { return ModInt(*this) -= other; } ModInt operator*(const ModInt &other) const { return ModInt(*this) *= other; } ModInt operator/(const ModInt &other) const { return ModInt(*this) /= other; } ModInt pow(ll x) const { ModInt ret(1), mul(value); while (x) { if (x & 1) ret *= mul; mul *= mul; x >>= 1; } return ret; } ModInt inv() const { return pow(MOD - 2); } bool operator==(const ModInt &other) const { return value == other.value; } bool operator!=(const ModInt &other) const { return value != other.value; } friend ostream &operator<<(ostream &os, const ModInt &x) { return os << x.value; } friend istream &operator>>(istream &is, ModInt &x) { ll v; is >> v; x = ModInt<MOD>(v); return is; } static constexpr ll get_mod() { return MOD; } }; using Mod998 = ModInt<998244353>; using Mod107 = ModInt<1000000007>; using mint = Mod998; struct Factors { Factors(int n) { mx = n; min_factor = vector<int>(mx + 1); is_prime = vector<bool>(mx + 1, true); is_prime[0] = is_prime[1] = false; divisors = vector<vector<int>>(mx + 1); prime_factors = vector<vector<pair<int, int>>>(mx + 1); for (int i = 2; i <= mx; i++) { if (is_prime[i]) { min_factor[i] = i; for (int j = 2 * i; j <= mx; j += i) { is_prime[j] = false; if (min_factor[j] == 0) { min_factor[j] = i; } } } } } vector<pair<int, int>> get_prime_factors(int n) { if (prime_factors[n].size() == 0) { int x = n; while (x > 1) { int p = min_factor[x]; int cnt = 0; while (x % p == 0) { x /= p; cnt++; } prime_factors[n].push_back({p, cnt}); } } return prime_factors[n]; } vector<int> get_divisors(int n) { if (divisors[n].size() == 0) { vector<pair<int, int>> pf = get_prime_factors(n); int sz = pf.size(); auto dfs = [&](auto &&dfs, int i, int x) -> void { if (i == sz) { divisors[n].push_back(x); return; } auto [p, cnt] = pf[i]; for (int j = 0; j <= cnt; j++) { dfs(dfs, i + 1, x); x *= p; } }; dfs(dfs, 0, 1); sort(divisors[n].begin(), divisors[n].end()); } return divisors[n]; } private: int mx; vector<int> min_factor; vector<bool> is_prime; vector<vector<int>> divisors; vector<vector<pair<int, int>>> prime_factors; }; int main() { int N; cin >> N; Factors fac(N); vector<int> cnt(N + 1); int all = 0; for (int i = 2; i <= N; i++) { auto pf = fac.get_prime_factors(i); for (auto [p, e] : pf) { cnt[p] += e; all += e; } } int mx = ranges::max(cnt); vector<mint> prod(all + 1, 1); for (int i = 2; i <= N; i++) { if (cnt[i] == 0) continue; for (int j = 1; j <= cnt[i]; j++) { prod[j] *= (cnt[i] / j + 1); } } mint ans = 0; for (int i = 1; i <= mx; i++) ans += prod[i] - 1; cout << ans << endl; }