結果

問題 No.2580 Hyperinflation
ユーザー noshi91
提出日時 2023-03-29 02:39:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 576 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 194,528 KB
最終ジャッジ日時 2025-02-11 18:57:24
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

constexpr int mod = 998244353;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> B(N);
  B[0] = 1;
  for (int i = 1; i < N; i++) {
    std::cin >> B[i];
    B[i] *= B[i - 1];
    if (B[i] > 1000000)
      std::abort();
  }

  std::string M_;
  std::cin >> M_;
  if (M_.size() >= 8)
    std::abort();
  const int M = std::stoi(M_);

  std::vector<int> dp(M + 1, 0);
  dp[0] = 1;
  for (const int e : B) {
    for (int i = e; i <= M; i++) {
      dp[i] += dp[i - e];
      dp[i] %= mod;
    }
  }

  std::cout << dp[M] << "\n";

  return 0;
}
0