結果

問題 No.1532 Different Products
ユーザー milanis48663220milanis48663220
提出日時 2021-06-04 22:56:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 986 ms / 4,000 ms
コード長 1,711 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 141,356 KB
実行使用メモリ 330,948 KB
最終ジャッジ日時 2023-08-12 16:27:10
合計ジャッジ時間 35,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 129 ms
56,720 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 9 ms
6,044 KB
testcase_09 AC 77 ms
33,296 KB
testcase_10 AC 185 ms
77,356 KB
testcase_11 AC 154 ms
64,940 KB
testcase_12 AC 449 ms
165,760 KB
testcase_13 AC 313 ms
124,776 KB
testcase_14 AC 728 ms
269,436 KB
testcase_15 AC 118 ms
41,604 KB
testcase_16 AC 144 ms
63,352 KB
testcase_17 AC 174 ms
74,388 KB
testcase_18 AC 177 ms
68,636 KB
testcase_19 AC 454 ms
160,364 KB
testcase_20 AC 803 ms
275,952 KB
testcase_21 AC 209 ms
89,548 KB
testcase_22 AC 300 ms
112,452 KB
testcase_23 AC 231 ms
91,696 KB
testcase_24 AC 713 ms
252,136 KB
testcase_25 AC 353 ms
141,796 KB
testcase_26 AC 52 ms
23,820 KB
testcase_27 AC 292 ms
120,116 KB
testcase_28 AC 227 ms
95,744 KB
testcase_29 AC 179 ms
73,980 KB
testcase_30 AC 383 ms
160,928 KB
testcase_31 AC 387 ms
163,188 KB
testcase_32 AC 474 ms
189,388 KB
testcase_33 AC 339 ms
147,768 KB
testcase_34 AC 568 ms
235,504 KB
testcase_35 AC 467 ms
188,468 KB
testcase_36 AC 577 ms
228,492 KB
testcase_37 AC 104 ms
38,720 KB
testcase_38 AC 607 ms
244,972 KB
testcase_39 AC 521 ms
217,924 KB
testcase_40 AC 612 ms
222,672 KB
testcase_41 AC 859 ms
321,048 KB
testcase_42 AC 734 ms
285,048 KB
testcase_43 AC 804 ms
298,392 KB
testcase_44 AC 876 ms
325,544 KB
testcase_45 AC 874 ms
326,320 KB
testcase_46 AC 879 ms
316,208 KB
testcase_47 AC 986 ms
329,708 KB
testcase_48 AC 960 ms
325,680 KB
testcase_49 AC 937 ms
327,548 KB
testcase_50 AC 876 ms
325,204 KB
testcase_51 AC 909 ms
328,568 KB
testcase_52 AC 898 ms
322,252 KB
testcase_53 AC 919 ms
329,852 KB
testcase_54 AC 882 ms
322,560 KB
testcase_55 AC 932 ms
326,936 KB
testcase_56 AC 847 ms
315,864 KB
testcase_57 AC 880 ms
318,644 KB
testcase_58 AC 916 ms
324,188 KB
testcase_59 AC 836 ms
306,008 KB
testcase_60 AC 875 ms
330,948 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 879 ms
326,796 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;
}


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<ll> dp(m*(n+1)); 
    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