HDU 1021 Fibonacci Again

来源:互联网 发布:超级优化女主角有谁 编辑:程序博客网 时间:2024/06/10 17:54
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
012345
 

Sample Output
nonoyesnonono
一看数据这么大 肯定是规律题 打表找下规律就行
#include <stdio.h>int a[1000000];int main(){    int n,i;    for(i=2,a[0]=7,a[1]=11;i<=1000000;i++)    {        a[i]=(a[i-1]+a[i-2])%3;    }    while(~scanf("%d",&n))        printf("%s\n",a[n]?"no":"yes");    return 33;}


0 0
原创粉丝点击