結果
問題 | No.1964 sum = length |
ユーザー | RVindicatio |
提出日時 | 2022-06-04 16:13:13 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 2,457 bytes |
コンパイル時間 | 3,349 ms |
コンパイル使用メモリ | 223,832 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 03:45:37 |
合計ジャッジ時間 | 5,381 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 3 ms
6,940 KB |
testcase_13 | AC | 4 ms
6,944 KB |
testcase_14 | AC | 7 ms
6,940 KB |
testcase_15 | AC | 10 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 3 ms
6,940 KB |
testcase_18 | AC | 4 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 60 ms
6,944 KB |
testcase_23 | AC | 56 ms
6,940 KB |
testcase_24 | AC | 24 ms
6,944 KB |
testcase_25 | AC | 30 ms
6,940 KB |
testcase_26 | AC | 67 ms
6,944 KB |
testcase_27 | AC | 40 ms
6,940 KB |
testcase_28 | AC | 28 ms
6,940 KB |
testcase_29 | AC | 49 ms
6,940 KB |
testcase_30 | AC | 31 ms
6,940 KB |
testcase_31 | AC | 66 ms
6,940 KB |
testcase_32 | AC | 13 ms
6,940 KB |
testcase_33 | AC | 12 ms
6,940 KB |
testcase_34 | AC | 55 ms
6,940 KB |
testcase_35 | AC | 17 ms
6,940 KB |
testcase_36 | AC | 35 ms
6,944 KB |
testcase_37 | AC | 47 ms
6,940 KB |
testcase_38 | AC | 71 ms
6,944 KB |
testcase_39 | AC | 29 ms
6,944 KB |
testcase_40 | AC | 32 ms
6,944 KB |
testcase_41 | AC | 61 ms
6,944 KB |
testcase_42 | AC | 76 ms
6,940 KB |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9; const ll inf = 1LL<<62; template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; }; template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } typedef ModInt<998244353> mint; void solve() { int n; cin >> n; vector<mint> c(2*n); int x = 1; while (1) { int p = x - ((int)to_string(x).size() - 1); if (p > 2*n - 1) break; c[p] += mint(1); x++; } vector<vector<mint>> dp(n+1, vector<mint>(2*n)); dp[0][0] = mint(1); for (int i=0; i<n; i++) { for (int j=0; j<2*n; j++) { for (int k=0; k<2*n; k++) { if (j+k >= 2*n) continue; dp[i+1][j+k] += dp[i][j]*c[k]; } } } cout << dp[n][2*n-1] << '\n'; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); // int t; cin >> t; /*while (t--)*/ solve(); }