結果

問題 No.1862 Copy and Paste
ユーザー Bryson NgBryson Ng
提出日時 2024-05-01 23:35:38
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 810 bytes
コンパイル時間 3,517 ms
コンパイル使用メモリ 277,556 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2024-05-01 23:35:45
合計ジャッジ時間 7,344 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,320 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 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 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void solve() {
	int a, b, n;
	cin >> a >> b >> n;
	// if your lucky
	if (n == 1) {
		cout << 0 << endl;
		return;
	}
	// temp answer
	int answer = a + (n - 1) * b;
	// start iterating
	for (int use_a = 2; (1 << (use_a - 1)) <= n; use_a++) {
		priority_queue<int, vector<int>, greater<int>> pq;
		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++) pq.push(2);
		while (pr < n) {
			int cur = pq.top();
			pq.pop();
			pr *= cur + 1;
			pr /= cur;
			use_b += 1;
			pq.push(cur + 1);
		}
		// looking for min
		answer = min(answer, a * use_a + b * use_b);
	}
	// couting final answer
	cout << answer << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();

	return 0;
}
0