結果

問題 No.1862 Copy and Paste
ユーザー vjudge1
提出日時 2024-11-13 09:25:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 76,552 KB
最終ジャッジ日時 2025-02-25 04:01:39
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
long long a,b;
long long n;
int main(){
	cin >> a >> b >> n;
	if(n==1){
		cout << 0;
		return 0;
	}
	long long ans=a+(n-1)*b;
	for(int i=2;(1ll<<(i-1))<=n;i++){
		priority_queue<int,vector<int>,greater<int>> p;
		long long pr=1;
		int j=i;
		for(int k=1;k<=i;k++){
			pr*=2;
		}
		for(int k=1;k<=i;k++){
			p.push(2);
		}
		while(pr<n){
			auto fnt=p.top();
			p.pop();
			pr=pr*(fnt+1)/fnt;
			++j;
			p.push(fnt+1);
		}
		ans=min(ans,a*i+b*j);
	}
	cout << ans;
	return 0;
}
0