結果

問題 No.2363 k-bonacci
ユーザー hitonanode
提出日時 2023-07-21 02:27:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 90,100 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 05:13:33
合計ジャッジ時間 2,119 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <numeric>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    long long N;
    cin >> N;

    for (int k = 2; k <= 70; ++k) {
        vector<__int128> vs(k + 1);
        vs.back() = 1;
        while (vs.back() < N) {
            __int128 sum = std::accumulate(vs.end() - k, vs.end(), __int128(0));
            vs.push_back(sum);
        }
        if (vs.back() == N) {
            cout << k << '\n';
            return 0;
        }
    }

    puts("-1");
}
0