結果
問題 |
No.2363 k-bonacci
|
ユーザー |
![]() |
提出日時 | 2023-06-30 01:39:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 2,082 ms |
コンパイル使用メモリ | 204,204 KB |
最終ジャッジ日時 | 2025-02-15 03:13:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#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(m.count(n)) cout<<m[n]<<endl; else cout<<-1<<endl; return 0; }