結果

問題 No.1731 Product of Subsequence
ユーザー sten_sansten_san
提出日時 2021-11-05 22:20:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 212,704 KB
実行使用メモリ 124,544 KB
最終ジャッジ日時 2024-04-24 06:09:44
合計ジャッジ時間 12,179 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 722 ms
120,576 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 34 ms
9,600 KB
testcase_09 WA -
testcase_10 AC 814 ms
124,416 KB
testcase_11 AC 695 ms
112,256 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 15 ms
6,272 KB
testcase_14 AC 627 ms
84,864 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 753 ms
124,416 KB
testcase_19 AC 15 ms
6,272 KB
testcase_20 AC 597 ms
88,320 KB
testcase_21 AC 803 ms
124,416 KB
testcase_22 AC 666 ms
124,544 KB
testcase_23 WA -
testcase_24 AC 19 ms
6,400 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 132 ms
22,528 KB
testcase_27 AC 198 ms
31,872 KB
testcase_28 AC 387 ms
60,800 KB
testcase_29 AC 157 ms
23,424 KB
testcase_30 AC 736 ms
124,416 KB
testcase_31 AC 664 ms
124,416 KB
testcase_32 WA -
testcase_33 AC 45 ms
11,648 KB
testcase_34 AC 62 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

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<int> div;
    for (int i = 1; i <= k / i; ++i) {
        if (k % i != 0) {
            continue;
        }
        div.insert(i);
        div.insert(k / i);
    }

    auto dp = vec<unordered_map<int, 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