結果

問題 No.1731 Product of Subsequence
ユーザー sten_sansten_san
提出日時 2021-11-05 22:21:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,464 bytes
コンパイル時間 2,759 ms
コンパイル使用メモリ 211,640 KB
最終ジャッジ日時 2025-01-25 12:28:39
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

#include <atcoder/modint>
using mint = atcoder::modint1000000007;

int main() {
    int n, k; cin >> n >> k;
    auto a = vec<int64_t>(uns, n);
    for (auto &e : a) cin >> e;

    set<int64_t> div;
    for (int64_t i = 1; i <= k / i; ++i) {
        if (k % i != 0) {
            continue;
        }
        div.insert(i);
        div.insert(k / i);
    }

    auto dp = vec<unordered_map<int64_t, mint>>(uns, n + 1);

    dp[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        auto v = a[i - 1];
        for (auto d : div) {
            dp[i][d] = dp[i - 1][d] + dp[i - 1][d / gcd(d, v)];
        }
    }

    cout << dp[n][k].val() << endl;
}

0