結果

問題 No.1862 Copy and Paste
ユーザー vjudge1vjudge1
提出日時 2024-05-01 16:57:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 204,680 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 16:57:22
合計ジャッジ時間 3,344 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define pb push_back
#define endl '\n'
using namespace std;

void solve() {
	int a,b,n;
	cin >> a >> b >> n;
	if (n == 1) {
		cout << 0 << endl;
		return;
	}
	int ans = a + (n - 1) * b;
	for (int use_a = 2; (1 << (use_a - 1)) <= n; use_a++) {
		priority_queue<int, vector<int>, greater<int>> p;
		int pr = 1;
		int use_b = use_a;
		for (int i = 1; i <= use_a; i++) pr *= 2;
		for (int i = 1; i <= use_a; i++) p.push(2);
		while (pr < n) {
			int cur = p.top();
			p.pop();
			pr *= cur + 1;
			pr /= cur;
			use_b += 1;
			p.push(cur + 1);
		}
		// cout << use_a << " " << use_b << " " << a * use_a + b * use_b << endl;
		ans = min(ans, a * use_a + b * use_b);
	} cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tttt = 1;
//	cin >> tttt;
	while (tttt--) solve();
}
0