結果

問題 No.1862 Copy and Paste
ユーザー ChipppppChippppp
提出日時 2022-02-25 19:03:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 3,853 ms
コンパイル使用メモリ 193,576 KB
最終ジャッジ日時 2025-01-28 01:48:35
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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