結果

問題 No.3716 Keep it Integer
コンテスト
ユーザー 👑 loop0919
提出日時 2026-08-22 18:46:03
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 113 ms / 2,000 ms
+ 454µs
コード長 730 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,227 ms
コンパイル使用メモリ 343,716 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-18 20:50:36
合計ジャッジ時間 7,222 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using ll = long long;
using mint = modint998244353;

int main() {
    int N; ll X;
    cin >> N >> X;

    vector<ll> A(N);
    for (auto& a: A) cin >> a;

    unordered_map<ll, mint> dp;
    dp[X] = 1;

    for (const auto& a: A) {
        unordered_map<ll, mint> ndp;

        for (const auto& [_, cnt]: dp) {
            ndp[a] += cnt;
        }

        for (const auto& [key, cnt]: dp) {
            if (key % a == 0) {
                ndp[key / a] += cnt;
            }
        }
        swap(dp, ndp);
    }

    mint ans = 0;
    for (const auto& [_, cnt]: dp) {
        ans += cnt;
    }

    cout << ans.val() << '\n';
}
0