結果

問題 No.1862 Copy and Paste
ユーザー Chippppp
提出日時 2022-02-24 23:24:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 4,518 ms
コンパイル使用メモリ 192,240 KB
最終ジャッジ日時 2025-01-28 01:41:01
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 1 WA * 5 TLE * 21
権限があれば一括ダウンロードができます

ソースコード

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 / 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