結果

問題 No.2416 vs Slime
ユーザー yansi819
提出日時 2024-03-18 10:46:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 4,380 ms
コンパイル使用メモリ 255,880 KB
最終ジャッジ日時 2025-02-20 07:12:33
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

map<ll, ll> mp;

ll solve(ll h, ll a) {
  if (h / a == 0) return 1;
  if (mp.count(h)) return mp[h];
  ll res = 1;
  for (int i = 0; i < 2; i++) {
    res += solve(h / a, a);
  }
  return mp[h] = res;
}

int main() {
  ll H, A; cin >> H >> A;
  cout << solve(H, A) << endl;
  return 0;
}
0