美文网首页
CodeFoeces-199A

CodeFoeces-199A

作者: ss5smi | 来源:发表于2018-03-05 14:43 被阅读0次

题目

原题链接:A. Hexadecimal's theorem

题意

给出数字n,问是否能在菲波那切数列找到三个之和等于他的数。

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    int s[10000],l;
    s[0]=0,s[1]=1;
    for(l=2;;l++){
        s[l]=s[l-2]+s[l-1];
        if(s[l]>1e9) break;
    }
    int n;
    cin>>n;
    for(int i=0;i<l;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<l;k++){
                if(s[i]+s[j]+s[k]==n){
                    printf("%d %d %d\n",s[i],s[j],s[k]);
                    return 0;
                }
            }
        }
    }
    printf("I'm too stupid to solve this problem\n");
    return 0;
}

相关文章

  • CodeFoeces-199A

    题目 原题链接:A. Hexadecimal's theorem 题意 给出数字n,问是否能在菲波那切数列找到三个...

网友评论

      本文标题:CodeFoeces-199A

      本文链接:https://www.haomeiwen.com/subject/nvhhfftx.html