結果

問題 No.954 Result
ユーザー yolishyolish
提出日時 2020-01-23 22:00:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,164 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 71,264 KB
実行使用メモリ 813,644 KB
最終ジャッジ日時 2023-09-28 12:38:39
合計ジャッジ時間 5,313 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int count_fib(vector<int> &v) {
    int max_v = 0;

    for(int i=0; i<v.size(); i++) {
        if(max_v < v[i]) {
            max_v = v[i];
        }
    }


    int a = 1;
    int b = 0;
    int ans = 0;
    vector<int> fib_v;

    for(int i=0; i<max_v; i++) {
        ans = a + b;
        fib_v.push_back(ans);
        a = b;
        b = ans;
    }

    vector<int> count_v;
    int counter = 0;
    int n = 0;
    for(int i=0; i<v.size(); i++) {
        for(int j=fib_v.size(); j>0; j--) {
            if(v[i] == fib_v[j]) {
                n = i;
                for(int k=j; k>0; k--) {
                    if(v[n] == fib_v[k]) {
                        n--;
                    } else if(n!=0){
                        continue;
                    } else {
                        goto exit;
                    }
                }
            }
        }
    }


    exit:

    return counter;
}

int main() {

    int N = 5;
    vector<int> v;
    int x;
    for(int i=0; i<N; i++) {
        cin >> x;
        v.push_back(x);
    }

    cout << count_fib(v);

    return 0;
}
0