結果

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

ソースコード

diff #

#include<bits/stdc++.h>
#define il inline 
#define re register
#define LL __int128
#define ll long long
using namespace std;
const int N=1e6+10;
#define gc() getchar()
il int rd(){
	int x=0,f=1;
	char ch=gc();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=gc();
	return x*f;
}
il void print(LL x){
	if(x>9)print(x/10);
	putchar(x%10+'0');
}
ll n,x,y;
int f[65];
void Main(){
	cin>>x>>y>>n;
	LL Ans=x+(LL)n*y;
//	print(Ans);puts("");
	ll p=sqrt(n),q=p;
	if(p*q<n){
		++q;
		if(p*q<n)++p;
	}
	Ans=min(Ans,(LL)max(0ll,p-2+q-2)*y+2*(x+y));
	for(int i=3; (1ll<<i)<=n; ++i){//????copy
		ll s=1ll<<i;
		LL ans=(LL)i*(x+y);
		int head=0;
		for(int j=1; j<=i; ++j)f[j]=2;
		while(s<n){
			++head;if(head>i)head=1;
			s=s/f[head]*(f[head]+1);
			++f[head];ans+=y;
			if(ans>Ans)break;
		}
//		cout<<i<<endl;
		Ans=min(Ans,ans);
	}
	print(Ans);
}
/*
  1000000000000000000 1 1
 */
signed main(){
//	freopen("dice.in","r",stdin);
//	freopen("dice.out","w",stdout);
	int T=1;
	while(T--)Main();
	return 0;
}
0