結果

問題 No.1532 Different Products
ユーザー sten_san
提出日時 2021-06-04 21:52:17
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,343 bytes
コンパイル時間 6,266 ms
コンパイル使用メモリ 264,496 KB
最終ジャッジ日時 2025-01-22 00:43:15
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34 TLE * 21 MLE * 7
権限があれば一括ダウンロードができます

ソースコード

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;

    map<tuple<int, int64_t>, tuple<int64_t, bool>> memo;

    auto solve = [&](auto &&self, int i, int64_t j) -> int64_t {
        auto &[ans, vis] = memo[{ i, j }];

        if (i == 0) {
            return 0 < j;
        }

        if (j == 0) {
            return 0;
        }

        if (vis) {
            return ans;
        }
        vis = true;

        return ans = self(self, i - 1, j) + self(self, i - 1, j / i);
    };

    cout << solve(solve, n, k) - 1 << endl;
}

0