結果

問題 No.1532 Different Products
ユーザー milanis48663220milanis48663220
提出日時 2021-06-04 22:54:53
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,704 bytes
コンパイル時間 6,767 ms
コンパイル使用メモリ 171,892 KB
最終ジャッジ日時 2025-01-22 02:52:31
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 59 RE * 3
権限があれば一括ダウンロードができます

ソースコード

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