結果

問題 No.2313 Product of Subsequence (hard)
ユーザー あるふぁ
提出日時 2026-09-30 07:25:16
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 1,033 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,638 ms
コンパイル使用メモリ 200,032 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-09-30 07:25:36
合計ジャッジ時間 13,097 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;

map<int, int> pf(int n){
    map<int, int> res;
    for (int p = 2; p*p <= n; p++){
        while (n%p == 0){
            res[p]++;
            n /= p;
        }
    }
    if (n > 1) res[n]++;
    return res;
}

int main(){
    int N, _K;
    cin >> N >> _K;
    auto K = pf(_K);
    vector<int> L;
    for (auto [k, v] : K) L.push_back(v);

    map<vector<int>, mint> dp, ep;
    dp[vector<int>(L.size(), 0)] = 1;
    for (int _ = 0; _ < N; _++){
        int __x;
        cin >> __x;
        auto _x = pf(__x);
        vector<int> x;
        for (auto [k, v] : K) x.push_back(_x[k]);
        for (auto [k, v] : dp){
            ep[k] += v;
            auto nk = k;
            for (int i = 0; i < k.size(); i++){
                nk[i] = min(nk[i]+x[i], L[i]);
            }
            ep[nk] += v;
        }
        dp.swap(ep);
        ep.clear();
    }

    cout << dp[L].val() << endl;
}
0