結果

問題 No.1532 Different Products
ユーザー milanis48663220milanis48663220
提出日時 2021-06-04 22:41:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,010 ms / 4,000 ms
コード長 1,763 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 147,272 KB
実行使用メモリ 334,116 KB
最終ジャッジ日時 2024-05-20 14:39:25
合計ジャッジ時間 97,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 341 ms
58,232 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 14 ms
6,944 KB
testcase_09 AC 177 ms
35,628 KB
testcase_10 AC 489 ms
81,144 KB
testcase_11 AC 371 ms
67,160 KB
testcase_12 AC 1,208 ms
169,520 KB
testcase_13 AC 871 ms
129,016 KB
testcase_14 AC 2,235 ms
273,336 KB
testcase_15 AC 226 ms
44,400 KB
testcase_16 AC 388 ms
64,340 KB
testcase_17 AC 446 ms
78,388 KB
testcase_18 AC 428 ms
72,384 KB
testcase_19 AC 1,211 ms
164,204 KB
testcase_20 AC 2,383 ms
280,336 KB
testcase_21 AC 602 ms
91,084 KB
testcase_22 AC 737 ms
117,320 KB
testcase_23 AC 613 ms
94,592 KB
testcase_24 AC 2,125 ms
257,508 KB
testcase_25 AC 987 ms
146,100 KB
testcase_26 AC 117 ms
25,032 KB
testcase_27 AC 793 ms
122,064 KB
testcase_28 AC 598 ms
97,704 KB
testcase_29 AC 477 ms
74,628 KB
testcase_30 AC 1,116 ms
162,492 KB
testcase_31 AC 1,147 ms
167,012 KB
testcase_32 AC 1,319 ms
192,604 KB
testcase_33 AC 1,227 ms
149,084 KB
testcase_34 AC 2,182 ms
239,096 KB
testcase_35 AC 1,426 ms
192,580 KB
testcase_36 AC 1,845 ms
232,140 KB
testcase_37 AC 238 ms
39,040 KB
testcase_38 AC 2,028 ms
248,684 KB
testcase_39 AC 1,630 ms
221,452 KB
testcase_40 AC 1,730 ms
227,292 KB
testcase_41 AC 2,824 ms
324,288 KB
testcase_42 AC 2,440 ms
289,244 KB
testcase_43 AC 2,594 ms
301,244 KB
testcase_44 AC 2,964 ms
328,536 KB
testcase_45 AC 2,902 ms
329,212 KB
testcase_46 AC 2,685 ms
319,332 KB
testcase_47 AC 2,958 ms
332,788 KB
testcase_48 AC 2,952 ms
328,996 KB
testcase_49 AC 2,969 ms
330,656 KB
testcase_50 AC 2,878 ms
328,252 KB
testcase_51 AC 2,894 ms
331,688 KB
testcase_52 AC 2,858 ms
325,312 KB
testcase_53 AC 3,010 ms
333,060 KB
testcase_54 AC 2,904 ms
325,596 KB
testcase_55 AC 2,965 ms
330,112 KB
testcase_56 AC 2,791 ms
319,032 KB
testcase_57 AC 2,784 ms
321,568 KB
testcase_58 AC 2,954 ms
327,520 KB
testcase_59 AC 2,706 ms
309,140 KB
testcase_60 AC 2,999 ms
334,116 KB
testcase_61 AC 2 ms
6,940 KB
testcase_62 AC 2 ms
6,944 KB
testcase_63 AC 2,868 ms
329,812 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<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];
            ll x = v[j]/i;
            if(x == 0) continue;
            dp[inv[x]][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