結果

問題 No.1532 Different Products
ユーザー sten_sansten_san
提出日時 2021-06-04 22:37:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,592 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 221,896 KB
実行使用メモリ 354,156 KB
最終ジャッジ日時 2024-04-30 10:23:29
合計ジャッジ時間 23,919 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 636 ms
66,916 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 10 ms
6,940 KB
testcase_09 AC 162 ms
21,112 KB
testcase_10 AC 783 ms
80,636 KB
testcase_11 AC 579 ms
59,828 KB
testcase_12 AC 2,101 ms
188,840 KB
testcase_13 AC 897 ms
92,740 KB
testcase_14 AC 3,789 ms
291,448 KB
testcase_15 AC 17 ms
6,944 KB
testcase_16 AC 792 ms
76,552 KB
testcase_17 AC 600 ms
59,144 KB
testcase_18 AC 392 ms
42,116 KB
testcase_19 AC 2,029 ms
182,912 KB
testcase_20 AC 3,994 ms
298,068 KB
testcase_21 AC 1,062 ms
104,140 KB
testcase_22 AC 1,130 ms
111,532 KB
testcase_23 AC 524 ms
54,924 KB
testcase_24 AC 3,597 ms
276,736 KB
testcase_25 AC 1,706 ms
161,968 KB
testcase_26 AC 187 ms
23,680 KB
testcase_27 AC 1,471 ms
141,248 KB
testcase_28 AC 1,124 ms
110,556 KB
testcase_29 AC 1,083 ms
105,192 KB
testcase_30 AC 2,033 ms
183,648 KB
testcase_31 AC 2,042 ms
184,900 KB
testcase_32 AC 2,474 ms
209,540 KB
testcase_33 AC 1,772 ms
167,092 KB
testcase_34 AC 3,134 ms
252,480 KB
testcase_35 AC 2,438 ms
208,060 KB
testcase_36 AC 3,141 ms
246,744 KB
testcase_37 AC 704 ms
72,192 KB
testcase_38 AC 3,466 ms
265,244 KB
testcase_39 AC 2,904 ms
234,588 KB
testcase_40 AC 3,290 ms
239,508 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
testcase_61 AC 2 ms
6,944 KB
testcase_62 AC 2 ms
6,940 KB
testcase_63 TLE -
権限があれば一括ダウンロードができます

ソースコード

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); }

int main() {
    int64_t n, k; cin >> n >> k;

    auto update = vec<int64_t>(uns, n + 1, 0);

    update[n].push_back(k);
    for (int i = n; 0 < i; --i) {
        auto s = vec<int64_t>(uns, 0);
        for (auto v : update[i]) {
            s.push_back(v);
            s.push_back(v / i);
        }

        sort(begin(s), end(s));
        s.erase(unique(begin(s), end(s)), end(s));

        for (auto v : s) {
            update[i - 1].push_back(v);
        }
    }

    map<tuple<int, int64_t>, int64_t> dp;
    for (auto v : update[0]) {
        dp[{ 0, v }] = 0 < v;
    }

    for (int i = 1; i <= n; ++i) {
        for (auto v : update[i]) {
            dp[{ i, v }] = dp[{ i - 1, v }] + dp[{ i - 1, v / i }];
        }
    }

    cout << dp[{ n, k }] - 1 << endl;
}

0