結果

問題 No.954 Result
ユーザー kyoprouno
提出日時 2019-12-17 01:30:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 930 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 170,548 KB
実行使用メモリ 125,696 KB
最終ジャッジ日時 2024-07-02 21:03:54
合計ジャッジ時間 16,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 7
other RE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const long long INF=1000000000+5;

vector<bool> flag(INF,false);
vector<long long> memo(1000000000,0);

long long fib(long long n){
    if(n<=1){
        flag[1]=true;
        return 1;
    }
    if(memo[n]!=0){
        return memo[n];
    }
    memo[n]=fib(n-1)+fib(n-2);
    flag[memo[n]]=true;
    return memo[n];
}

int main(){
    vector<long long> a(5);
    for(int i=0;i<5;i++){
        cin >> a[i];
    }
    int i=1;
    while(fib(i)<=INF){
        i*=2;
    }
    if(flag[a[4]]==true && flag[a[3]]==true && flag[abs(a[3]-a[4])]==true && a[4]<a[3]){
        for(int i=2;i>=0;i--){
            if(a[i]!=a[i+1]+a[i+2]){
                cout << 5-i-1 << endl;
                return 0;
            }
        }
        cout << 5 << endl;
        return 0;
    }
    if(flag[a[4]]==true){
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}
0