結果

問題 No.1532 Different Products
ユーザー milanis48663220milanis48663220
提出日時 2021-06-04 22:36:22
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,921 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 148,344 KB
実行使用メモリ 415,988 KB
最終ジャッジ日時 2024-04-30 10:03:53
合計ジャッジ時間 14,780 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,880 KB
testcase_01 AC 608 ms
85,368 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 13 ms
7,808 KB
testcase_09 AC 233 ms
50,736 KB
testcase_10 AC 925 ms
119,248 KB
testcase_11 AC 693 ms
97,648 KB
testcase_12 AC 2,839 ms
253,088 KB
testcase_13 AC 1,897 ms
190,468 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

vector<ll> calc(ll k){
    set<ll> st;
    for(ll i = 1; i*i <= k; i++){
        st.insert(i);
        st.insert(k/i);
    }
    vector<ll> ans;
    for(ll x: st) ans.push_back(x);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; ll k; cin >> n >> k;
    auto v = calc(k);
    int m = v.size();
    unordered_map<ll, int> inv = [&](){
        unordered_map<ll, int> ans;
        for(int i = 0; i < m; i++) ans[v[i]] = i;
        return ans;
    }();
    vector<vector<int>> nx(m, vector<int>(n+1)); // nx[i][j] = v[i]/j
    for(int i = 0; i < m; i++){
        for(int j = 1; j <= n; j++){
            ll x = v[i]/j;
            if(x == 0) nx[i][j] = -1;
            else nx[i][j] = inv[x];
        }
    }
    vector<vector<ll>> dp(m, vector<ll>(n+1)); // nx[i][j] = v[i]/j
    dp[m-1][n] = 1;
    for(int i = n; i >= 1; i--){
        for(int j = 0; j < m; j++){
            dp[j][i-1] += dp[j][i];
            int k = nx[j][i];
            if(k == -1) continue;
            dp[k][i-1] += dp[j][i];
        }
        // for(int j = 0; j < m; j++) cout << dp[i-1][j] << ' ';
        // cout << endl;
    }
    ll ans = 0;
    for(int j = 0; j < m; j++) ans += dp[j][0];
    cout << ans-1 << endl;
}
0