結果

問題 No.1862 Copy and Paste
ユーザー vjudge1vjudge1
提出日時 2024-11-13 09:36:47
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 201,072 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-13 09:36:51
合計ジャッジ時間 3,576 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 24 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define il inline 
#define re register
#define int long long
using namespace std;
const int N=1e6+10,INF=LONG_LONG_MAX;
#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;
}
int n,x,y;
int f[61];
void Main(){
	x=rd(),y=rd();n=rd();
	int lim=__lg(n),Ans=x+n*y;
	int p=sqrt(n),q=p;
	if(p*p<n)++q;
	Ans=min(Ans,((p-2)+(q-2))*y+2*(x+y));
	for(int i=3; i<=lim+1; ++i){//????copy
		int s=1ll<<i,ans=i*(x+y),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);
	}
	cout<<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