結果
| 問題 |
No.1664 Unstable f(n)
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-09-03 22:48:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 3,652 ms |
| コンパイル使用メモリ | 229,848 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-15 15:59:53 |
| 合計ジャッジ時間 | 4,438 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MAX 100000
#define MOD 1000000007
#define INF 1000000000000000000
int main(){
ll n;
cin>>n;
ll ans=n+1;
for(ll i=2;i<=1000000;i++){
ll x=1;
int j=0;
while(x<=n/i){
x*=i;
j++;
ans=min<ll>(ans,i+(ll)j+n-x);
}
}
ll left=0;
ll right=1000000001;
while(left+1<right){
ll x=(left+right)/2;
if(x*x<=n){
left=x;
}else{
right=x;
}
}
ans=min<ll>(ans,left+2+n-left*left);
cout<<ans<<'\n';
}
monnu