結果
| 問題 |
No.1532 Different Products
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-06-04 21:59:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,854 bytes |
| コンパイル時間 | 1,368 ms |
| コンパイル使用メモリ | 129,660 KB |
| 最終ジャッジ日時 | 2025-01-22 01:00:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 MLE * 1 |
| other | AC * 20 TLE * 24 MLE * 18 |
ソースコード
#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;
ll dp[205][300000];
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();
map<ll, int> inv = [&](){
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];
}
}
dp[n][m-1] = 1;
for(int i = n; i >= 1; i--){
for(int j = 0; j < m; j++){
dp[i-1][j] += dp[i][j];
int k = nx[j][i];
if(k == -1) continue;
dp[i-1][k] += dp[i][j];
}
// for(int j = 0; j < m; j++) cout << dp[i-1][j] << ' ';
// cout << endl;
}
ll ans = 0;
for(int i = 0; i < m; i++) ans += dp[0][i];
cout << ans-1 << endl;
}
milanis48663220