結果
問題 |
No.2363 k-bonacci
|
ユーザー |
![]() |
提出日時 | 2023-07-05 15:57:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 468 ms |
コンパイル使用メモリ | 53,632 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 10:06:58 |
合計ジャッジ時間 | 2,212 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
/* -*- coding: utf-8 -*- * * 2363.cc: No.2363 k-bonacci - yukicoder */ #include<cstdio> #include<deque> #include<algorithm> using namespace std; /* constant */ /* typedef */ typedef long long ll; typedef deque<ll> dql; /* global variables */ /* subroutines */ /* main */ int main() { ll n; scanf("%lld", &n); for (int k = 2; k <= 63; k++) { dql xs(k, 0); xs[k - 1] = 1; ll sum = 1; while (sum <= n) { if (sum == n) { printf("%d\n", k); return 0; } xs.push_back(sum); sum *= 2; while (xs.size() > k) { sum -= xs.front(); xs.pop_front(); } } } puts("-1"); return 0; }