結果

問題 No.1964 sum = length
ユーザー RVindicatioRVindicatio
提出日時 2022-06-04 16:13:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 2,457 bytes
コンパイル時間 3,304 ms
コンパイル使用メモリ 223,688 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 02:44:55
合計ジャッジ時間 5,655 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 7 ms
4,348 KB
testcase_15 AC 10 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 59 ms
4,348 KB
testcase_23 AC 57 ms
4,348 KB
testcase_24 AC 23 ms
4,348 KB
testcase_25 AC 30 ms
4,348 KB
testcase_26 AC 66 ms
4,348 KB
testcase_27 AC 39 ms
4,348 KB
testcase_28 AC 28 ms
4,348 KB
testcase_29 AC 49 ms
4,348 KB
testcase_30 AC 31 ms
4,348 KB
testcase_31 AC 66 ms
4,348 KB
testcase_32 AC 12 ms
4,348 KB
testcase_33 AC 12 ms
4,348 KB
testcase_34 AC 55 ms
4,348 KB
testcase_35 AC 18 ms
4,348 KB
testcase_36 AC 34 ms
4,348 KB
testcase_37 AC 47 ms
4,348 KB
testcase_38 AC 72 ms
4,348 KB
testcase_39 AC 29 ms
4,348 KB
testcase_40 AC 32 ms
4,348 KB
testcase_41 AC 61 ms
4,348 KB
testcase_42 AC 77 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
}
0