Fibonacci Again
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
Sample Output
F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).给定一个n,f[n]%3==0 就输出yes,否则输出no。不能直接做的,不然超出数的范围。我打出0~40的数跟可不可以被3整除如下图所示:

你会发现,可以的n-2可以被4整除。代码如下:
#include<cstdio>
int main(){
int n;
while(scanf("%d",&n)!=EOF){
if((n-2)%4==0) printf("yes\n");
else printf("no\n");
}
return 0;
}

另外记录一下最近在HDU A题的情况:

版权声明:本文为博主原创文章,未经博主允许不得转载。
HDU 1021.Fibonacci Again【规律】【不可直接求】【8月18】
原文:http://blog.csdn.net/a995549572/article/details/47759235