結果

問題 No.1532 Different Products
ユーザー milanis48663220milanis48663220
提出日時 2021-06-04 22:54:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,704 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 142,392 KB
実行使用メモリ 238,940 KB
最終ジャッジ日時 2024-04-30 11:20:57
合計ジャッジ時間 27,758 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 132 ms
50,660 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 71 ms
28,564 KB
testcase_10 AC 188 ms
65,696 KB
testcase_11 AC 153 ms
56,848 KB
testcase_12 AC 390 ms
128,532 KB
testcase_13 AC 278 ms
97,720 KB
testcase_14 AC 625 ms
199,864 KB
testcase_15 AC 85 ms
26,152 KB
testcase_16 AC 148 ms
56,044 KB
testcase_17 AC 170 ms
63,016 KB
testcase_18 AC 152 ms
54,344 KB
testcase_19 AC 385 ms
125,432 KB
testcase_20 AC 601 ms
204,636 KB
testcase_21 AC 203 ms
75,848 KB
testcase_22 AC 269 ms
91,444 KB
testcase_23 AC 200 ms
71,416 KB
testcase_24 AC 581 ms
188,232 KB
testcase_25 AC 332 ms
113,364 KB
testcase_26 AC 54 ms
23,352 KB
testcase_27 AC 279 ms
99,636 KB
testcase_28 AC 228 ms
80,052 KB
testcase_29 AC 183 ms
65,912 KB
testcase_30 AC 364 ms
129,976 KB
testcase_31 AC 382 ms
130,168 KB
testcase_32 AC 442 ms
147,868 KB
testcase_33 AC 345 ms
118,128 KB
testcase_34 AC 553 ms
176,116 KB
testcase_35 AC 442 ms
147,540 KB
testcase_36 AC 526 ms
174,720 KB
testcase_37 AC 107 ms
36,724 KB
testcase_38 AC 542 ms
183,576 KB
testcase_39 AC 503 ms
165,180 KB
testcase_40 AC 550 ms
168,200 KB
testcase_41 AC 764 ms
232,412 KB
testcase_42 AC 668 ms
209,452 KB
testcase_43 AC 665 ms
219,180 KB
testcase_44 AC 736 ms
237,468 KB
testcase_45 AC 760 ms
237,624 KB
testcase_46 AC 731 ms
231,400 KB
testcase_47 RE -
testcase_48 AC 841 ms
237,604 KB
testcase_49 AC 740 ms
238,304 KB
testcase_50 AC 735 ms
237,328 KB
testcase_51 AC 763 ms
238,940 KB
testcase_52 AC 703 ms
236,336 KB
testcase_53 RE -
testcase_54 AC 743 ms
235,196 KB
testcase_55 AC 767 ms
238,932 KB
testcase_56 AC 753 ms
232,796 KB
testcase_57 AC 711 ms
234,032 KB
testcase_58 AC 740 ms
236,780 KB
testcase_59 AC 706 ms
225,552 KB
testcase_60 RE -
testcase_61 AC 1 ms
6,940 KB
testcase_62 AC 2 ms
6,944 KB
testcase_63 AC 763 ms
238,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

ll dp[40000500];

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;
    }();
    
    dp[(m-1)*(n+1)+n] = 1;
    for(int i = n; i >= 1; i--){
        for(int j = 0; j < m; j++){
            if(dp[j*(n+1)+i] == 0) continue;
            dp[j*(n+1)+i-1] +=  dp[j*(n+1)+i];
            ll x = v[j]/i;
            if(x == 0) continue;
            dp[inv[x]*(n+1)+i-1] +=  dp[j*(n+1)+i];
        }
    }

    ll ans = 0;
    for(int j = 0; j < m; j++) ans += dp[j*(n+1)+0];
    cout << ans-1 << endl;
}
0