結果
問題 | No.1532 Different Products |
ユーザー |
![]() |
提出日時 | 2021-06-04 21:59:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,455 ms / 4,000 ms |
コード長 | 1,908 bytes |
コンパイル時間 | 1,391 ms |
コンパイル使用メモリ | 130,184 KB |
最終ジャッジ日時 | 2025-01-22 00:57:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 62 |
ソースコード
#include <iostream>#include <algorithm>#include <map>#include <set>#include <queue>#include <bitset>#include <climits>#include <cmath>#include <complex>#include <functional>#include <cassert>#include <stack>#include <numeric>#include <iomanip>#include <limits>#include <random>#include <unordered_map>#include <chrono>typedef int64_t ll;typedef std::pair<int, int> Pii;typedef std::pair<ll, ll> Pll;typedef std::pair<double, double> Pdd;#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)#define all(_l) _l.begin(), _l.end()#define rall(_l) _l.rbegin(), _l.rend()#define MM << " " <<template<typename _T>using MaxHeap = std::priority_queue<_T>;template<typename _T>using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;template<typename _T>inline bool chmax(_T &_l, const _T _b) {if (_l < _b) {_l = _b;return true;}return false;}template<typename _T>inline bool chmin(_T &_l, const _T _b) {if (_l > _b) {_l = _b;return true;}return false;}template<typename _T>void vdeb(const std::vector<_T> &bb) {for (unsigned int i = 0;i < bb.size();i++) {if (i == bb.size() - 1) std::cout << bb[i];else std::cout << bb[i] << ' ';}std::cout << '\n';}template<typename _T>void vdeb(const std::vector<std::vector<_T>> &bb) {for (unsigned int i = 0;i < bb.size();i++) {// std::cout << i << ' ';vdeb(bb[i]);}std::cout << '\n';}using namespace std;int main() {ll n, k; cin >> n >> k;unordered_map<ll, ll> mp;auto rec = [&](auto &&f, ll x, ll y) -> ll {if(y == 1) return 2;if(mp.count(x*1000+y)) return mp[x*1000+y];if(x < y) return mp[x*1000+y] = f(f, x, y-1);return mp[x*1000+y] = f(f, x, y-1) + f(f, x/y, y-1);};cout << rec(rec, k, n)-1 << endl;}