結果
| 問題 |
No.1862 Copy and Paste
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-18 12:56:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,017 bytes |
| コンパイル時間 | 880 ms |
| コンパイル使用メモリ | 76,500 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 12:56:28 |
| 合計ジャッジ時間 | 2,088 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#define fio(fn) freopen(fn".in", "r", stdin), freopen(fn".out", "w", stdout)
using namespace std;
using ll = long long;
ll n, x, y;
// chr_count, clipboard = time
//ll f[7005][7005];
int main()
{
// fio("dice");
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
// memset(f, 0x3f, sizeof f);
// f[1][0] = 0;
cin >> x >> y >> n;
// n++;
if (n == 1) {
cout << "0\n";
return 0;
}
ll ans = 0x3f3f3f3f3f3f3f3fll;
for (int i = 1; ; i++) {
ll a = floor(pow(n, 1. / i)), b = ceil(pow(n, 1. / i));
vector<ll> pwra(i + 1), pwrb(i + 1);
pwra[0] = pwrb[0] = 1;
for (int j = 1; j <= i; j++) {
pwra[j] = pwra[j - 1] * a;
pwrb[j] = pwrb[j - 1] * b;
}
// 边界修正
for (int j = 0; j <= i; j++) {
if (pwra[j] * pwrb[i - j] >= n) {
ans = min(ans,
(x + y * (a - 1)) * j +
(x + y * (b - 1)) * (i - j)
);
}
}
if (b <= 2) break;
}
cout << ans << '\n';
}