結果

問題 No.1862 Copy and Paste
ユーザー Chippppp
提出日時 2021-12-24 12:08:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 592 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 194,272 KB
最終ジャッジ日時 2025-01-27 06:11:43
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  long a, b;
  cin >> a >> b;
  long n;
  cin >> n;
  if (n == 1) {
    cout << 1 << '\n';
    return 0;
  }
  ll ans = 1LL << 61;
  for (int i = 1; ; ++i) {
    ll p = ceil(pow(n, 1.0 / i));
    ll ok = 0, ng = i;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if (pow(p - 1, (double)mid) * pow(p, (double)(i - mid)) >= n) ok = mid;
      else ng = mid;
    }
    ans = min(ans, (a + b * (p - 2)) * ok + (a + b * (p - 1)) * (i - ok));
    if (p == 2) break;
  }
  cout << (long)ans << '\n';
}
0