Y - Fibonacci Again

Subject

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 aninteger n. (n < 1,000,000). 

**************************************************************************************************

Output

Print the word "yes" if 3 divide evenly intoF(n). 

Print the word "no" if not. 

**************************************************************************************************

Sample Input

0

1

2

3

4

5

**************************************************************************************************

Sample Output

no

no

yes

no

no

no

**************************************************************************************************

找规律就好了。输出前几个看看,就出来了。

**************************************************************************************************

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int a[2]; 

int main()
{
	int n;
	a[0]=1;
	a[1]=1;
	while(scanf("%d",&n)!=EOF)
	{
		int sum;
		if(n<2){
			sum = a[n];
		}else{
		   sum = (n-2)%4;
		}
		if(!sum){
			 printf("yes\n");
		}else{
			 printf("no\n");
		}
	}
	return 0;
}
**************************************************************************************************

posted @ 2017-07-14 09:06  让你一生残梦  阅读(111)  评论(0)    收藏  举报