結果
| 問題 |
No.2363 k-bonacci
|
| ユーザー |
umezo
|
| 提出日時 | 2023-06-30 01:38:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 2,258 ms |
| コンパイル使用メモリ | 204,196 KB |
| 最終ジャッジ日時 | 2025-02-15 03:13:10 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 1 |
ソースコード
#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;
const ll INF=1e18;
map<ll,int> m;
void f(int x){
queue<ll> que;
ll now=1;
que.push(1);
while(now<=INF){
if(!m.count(now)) m[now]=x;
que.push(now);
now*=2;
if(que.size()>x){
now-=que.front();
que.pop();
}
}
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
for(int i=2;i<70;i++) f(i);
ll n;
cin>>n;
if(n==1) cout<<1<<endl;
else if(m.count(n)) cout<<m[n]<<endl;
else cout<<-1<<endl;
return 0;
}
umezo