結果

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a,b,ans;
signed main() {
	cin>>a>>b>>n;
	if(n==1) {
		cout<<0;
		return 0;
	}
	ans=a+(n-1)*b;
	for(int i=2;(1ll<<(i-1))<=n;i++) {
		priority_queue<int,vector<int>,greater<int> > p;
		int j=i,now=1;
		for(int k=1;k<=i;k++) {
			now*=2;
			p.push(2);
		}
		while(now<n) {
			int man=p.top();
			p.pop();
			now=now*(man+1)/man;
			j++;
			p.push(man+1);
		}
		ans=min(ans,a*i+b*j);
	}
	cout<<ans;
	return 0;
}
//log2^2
0