hdu 1021 Fibonacci Again

点击此处即可传送hdu 1021



 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 44439 Accepted Submission(s): 21214 Problem Description There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). Input Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000). Output Print the word "yes" if 3 divide evenly into F(n). Print the word "no" if not. Sample Input 0 1 2 3 4 5 Sample Output no no yes no no no 

解题思路:实在没啥说的,就是找寻环节,直接上代码吧,其实还可以用矩阵乘法做,感觉有点麻烦,但是为了学会矩阵乘法,我觉定要用矩阵做一下,当然这是待会的事情了,嘿嘿:

/* 2015 - 8 - 13 Author: ITAK 今日的我要超越昨日的我,明日的我要胜过今日的我, 以创作出更好的代码为目标,不断地超越自己。 */
#include <iostream>
#include <cstdio>
using namespace std;
int data[30];
int main()
{
    /* 打表看一下,找寻环节 data[0] = 7; data[1] = 11; for(int i=2; i<30; i++) data[i] = data[i-1]+data[i-2]; for(int i=0; i<30; i++) if(data[i]%3 == 0) cout<<i<<endl; */
    int m;
    while(~scanf("%d",&m))
    {
        if(m%4 == 2)
            puts("yes");
        else
            puts("no");
    }
    return 0;
}

你可能感兴趣的:(水)