結果

問題 No.473 和と積の和
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-12-19 22:52:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 401 ms / 3,000 ms
コード長 1,827 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 174,148 KB
実行使用メモリ 16,056 KB
最終ジャッジ日時 2023-08-22 08:01:11
合計ジャッジ時間 5,673 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 67 ms
6,472 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 401 ms
16,056 KB
testcase_26 AC 46 ms
5,848 KB
testcase_27 AC 83 ms
7,500 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 317 ms
13,076 KB
testcase_35 AC 302 ms
12,492 KB
testcase_36 AC 3 ms
4,384 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 283 ms
11,792 KB
testcase_39 AC 177 ms
8,896 KB
testcase_40 AC 197 ms
9,452 KB
testcase_41 AC 217 ms
10,236 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 3 ms
4,384 KB
testcase_44 AC 20 ms
4,560 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

using State = tuple<int, int, int>;
map<State, int> dp;

// y以上の整数n個からなる集合で、すべての要素の積がxとなるものの個数
int dfs(int n, int x, int y) {
    // output(n, x, y);
    if (x < y) return 0;
    if (n == 1) return 1;
    State s(n, x, y);
    if (dp.count(s)) return dp[s];
    int &ret = dp[s];
    for (int p = y; p * p <= x; ++p) {
        if (x % p) continue;
        ret += dfs(n - 1, x / p, p);
    }
    return ret;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, x;
    cin >> n >> x;
    cout << dfs(n, x + 1, 2) << endl;
}
0