結果

問題 No.1664 Unstable f(n)
ユーザー umezo
提出日時 2021-09-03 22:44:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 192,588 KB
最終ジャッジ日時 2025-01-24 06:36:17
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x;
    x=x*x;
    n/=2;
  }
  return ans;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n;
  cin>>n;
  
  ll ans=n;
  for(int i=2;i<=min(n,10000000LL);i++){
    ll j=log(n)/(log(i));
    ans=min(ans,i+j+n-modpow(i,j));
  }
  cout<<ans<<endl;
  
  return 0;
}
0