結果
問題 | No.1862 Copy and Paste |
ユーザー |
![]() |
提出日時 | 2024-11-15 21:17:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,193 bytes |
コンパイル時間 | 2,038 ms |
コンパイル使用メモリ | 195,404 KB |
最終ジャッジ日時 | 2025-02-25 04:18:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 27 |
コンパイルメッセージ
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",&N,&ax,&ay); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;#define il __int128il get_log(long long x){il cnt=1;il res=0;while(cnt<x){cnt*=2;res++;}return res;}il lgn,ans;il qpow(il x,il y){int res=1;while(y){if(y&1) res*=x;x*=x;y>>=1;}return res;}int ans1[1010],len;long long N,ax,ay;il solve(il k){il res=ceil(powl(N,(long double)(1.0/k)));il l=1,r=res,t=res;// cout<<k<<" "<<l<<" "<<r<<" "<<res*k<<endl;il resl=(il)res*k;for(il p=1;p<=k;p++){l=0,r=res;while(l<=r){il 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;}signed main(){scanf("%lld%lld%lld",&N,&ax,&ay);lgn=get_log(N);// cout<<"N?log??"<<" "<<lgn<<endl;// cout<<endl;for(il 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>(il)(ax-ay)*k+(il)ay*solve(k) ? (il)(ax-ay)*k+(il)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;}