結果
| 問題 |
No.2363 k-bonacci
|
| ユーザー |
|
| 提出日時 | 2023-07-24 13:17:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 989 ms |
| コンパイル使用メモリ | 107,404 KB |
| 最終ジャッジ日時 | 2025-02-15 18:44:54 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<random>
#include<bitset>
//#include<fstream>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
int main(){
ll N;
cin>>N;
/*
if(N==1){
cout<<1<<endl;
return 0;
}
*/
for(ll k=1;k<=62;k++){
//cout<<"k="<<k<<endl;
vector<ll> A(k+1,0);//A[0]~A[k-1]
A[k]=1;
for(ll i=k;;i++){
ll c=0;
for(ll j=0;j<=k;j++){
if(i-j<0) break;
c+=A[i-j];
}
if(c>N){
break;
}else if(c==N){
cout<<k+1<<endl;
return 0;
}else{
A.push_back(c);
}
}
}
cout<<-1<<endl;
return 0;
}