結果

問題 No.473 和と積の和
ユーザー PachicobuePachicobue
提出日時 2018-11-21 17:42:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 3,000 ms
コード長 1,483 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 217,112 KB
実行使用メモリ 17,244 KB
最終ジャッジ日時 2023-08-26 02:39:26
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 37 ms
9,716 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 122 ms
17,244 KB
testcase_26 AC 28 ms
8,448 KB
testcase_27 AC 43 ms
9,296 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 76 ms
10,704 KB
testcase_35 AC 66 ms
10,424 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 59 ms
10,496 KB
testcase_39 AC 29 ms
6,616 KB
testcase_40 AC 31 ms
6,732 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 31 ms
15,940 KB
testcase_43 AC 40 ms
16,024 KB
testcase_44 AC 51 ms
15,968 KB
testcase_45 AC 1 ms
4,384 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
template <typename T, typename A>
std::ostream& operator<<(std::ostream& os, const std::vector<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]\n");
}
int main()
{
    int N, X;
    std::cin >> N >> X, X++;
    if (N >= 30) { return std::cout << 0 << std::endl, 0; }
    std::vector<int> d;
    for (int i = 1; i * i <= X; i++) {
        if (X % i != 0) { continue; }
        d.push_back(i);
        if (i * i != X) { d.push_back(X / i); }
    }
    const int S = d.size();
    std::sort(d.begin(), d.end());
    std::unordered_map<int, int> mp;
    for (int i = 0; i < S; i++) { mp[d[i]] = i; }
    std::vector<std::vector<int>> dp(S, std::vector<int>(S, 0));  // 積=d[i], 最後に使った約数<=d[j]
    std::vector<std::vector<int>> tmp(S, std::vector<int>(S, 0));
    std::fill(dp[0].begin(), dp[0].end(), 1);
    for (int i = 0; i < N; i++) {
        for (int j = S - 1; j >= 0; j--) {
            for (int k = j; k >= 1; k--) {
                if (d[j] % d[k] == 0) { tmp[j][k] = dp[mp[d[j] / d[k]]][k]; }
            }
        }
        dp = tmp;
        for (int i = 0; i < S; i++) { std::fill(tmp[i].begin(), tmp[i].end(), 0); }
        for (int i = 0; i < S; i++) {
            for (int j = 1; j < S; j++) { dp[i][j] += dp[i][j - 1]; }
        }
    }
    std::cout << dp[S - 1][S - 1] << std::endl;
    return 0;
}
0