結果
| 問題 | 
                            No.1862 Copy and Paste
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vjudge1
                         | 
                    
| 提出日時 | 2024-11-15 19:50:48 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,176 bytes | 
| コンパイル時間 | 2,094 ms | 
| コンパイル使用メモリ | 194,628 KB | 
| 最終ジャッジ日時 | 2025-02-25 04:18:28 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 2 | 
| other | AC * 12 WA * 15 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |         scanf("%lld%lld%lld",&ax,&ay,&N);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
#define il __int128
#define ll long long
ll get_log(ll x){
	ll cnt=1;
	ll res=0;
	while(cnt<x){
		cnt*=2;
		res++;
	}
	return res;
} 
ll N,lgn,ax,ay,ans;
il qpow(ll x,ll y){
	int res=1;
	while(y){
		if(y&1) res*=x;
		x*=x;
		y>>=1;
	}
	return res;
}
il solve(ll k){
	ll res=ceil(powl(N,(long double)(1.0/k)));
	ll l=1,r=res,t=res;
//	cout<<k<<" "<<l<<" "<<r<<" "<<res*k<<endl;
	il resl=(il)res*k;
	for(ll p=1;p<=k;p++){
		l=1,r=res;
		while(l<=r){
			ll mid=(l+r)>>1 ;
			if(qpow(mid,p)*qpow(mid+1,k-p)>N){
				r=mid-1;
				t=mid;
			}else{
				l=mid+1;
			}
		}
		resl=(resl<t*p+(t+1)*(k-p) ? resl : t*p+(t+1)*(k-p));
	}
	return resl;
}
int ans1[1010],len;
signed main(){
	scanf("%lld%lld%lld",&ax,&ay,&N);
	lgn=get_log(N);
//	cout<<"N?log??"<<" "<<lgn<<endl;
//	cout<<endl; 
	for(ll k=1;k<=lgn;k++){
	//	cout<<"??"<<k<<"?"<<endl; 
		if(k==1) {
			ans=((il)(ax-ay)*k+(il)ay*solve(k));
			continue;
		}
	//	cout<<"???Ai"<<" "<<solve(k)<<endl; 
	    ans=(ans>(ax-ay)*k+ay*solve(k) ? (ax-ay)*k+ay*solve(k) : ans);
	}
	while(ans){
		ans1[++len]=ans%10;
		ans/=10;
	}
	for(int i=len;i>=1;i--){
		printf("%d",ans1[i]);
	} 
	return 0; 
}
            
            
            
        
            
vjudge1