結果
問題 | No.1862 Copy and Paste |
ユーザー |
![]() |
提出日時 | 2024-11-13 21:47:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 843 bytes |
コンパイル時間 | 1,831 ms |
コンパイル使用メモリ | 168,020 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-13 21:47:05 |
合計ジャッジ時間 | 3,295 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 24 WA * 3 |
ソースコード
#include<bits/stdc++.h> #define int __int128 using namespace std; int n,a,b,ans=1e15; int qread(){ int w=1,ret; char c; while((c=getchar())>'9'||c<'0')w=(c=='-')?-1:1; ret=c-'0'; while((c=getchar())>='0'&&c<='9')ret=ret*10+c-'0'; return w*ret; } int fpow(int n,int k){ int ret=1; for(;k;k>>=1){ if(k&1)ret=ret*n; n=n*n; } return ret; } bool check(int x,int y){ int z=1; while(y){ if(z*x>n)return true; z*=x; y--; } return false; } signed main(){ a=qread(); b=qread(); n=qread(); for(int i=1;i<=63;i++){ int l=1,r=n+1,z=1,res=0; while(l<r){ int mid=(l+r)>>1; if(check(mid,i))r=mid; else l=mid+1; } z=fpow(r,i); res=i*(a+b*(r-1)); for(int j=1;j<i;j++){ if(z/r*(r-1)>n){ z=z/r*(r-1); res-=b; } else break; } ans=min(res,ans); } printf("%lld",(long long)ans); return 0; }