結果

問題 No.1664 Unstable f(n)
ユーザー 同传man辛苦了
提出日時 2021-09-04 11:30:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 167,708 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 19:14:08
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long 
using namespace std;
int n,t,len,l;
int k;
int i,ans;
__int128 qpow(int x,int y){
	__int128 ans=1;
	while(y){
		if(y&1){
			ans*=x;
		}
		x*=x;
		y>>=1;
	}
	return ans;
}
signed main(){
	cin>>n;
	ans=n; 
	for(int j=log2(n);j>1;j--){
		l=pow(n,1.0/j);
		for(int i=l-1;qpow(i,j)<=n;i++){
				ans=min(ans,n-(int)qpow(i,j)+i+j);
				//cout<<i<<" "<<j<<" "<<n-qpow(i,j)<<endl;
		} 
		
	}             
	cout<<ans<<endl;                
										
	 
    return 0;
}
0