___________一个简单题带来的启示____________________________

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

题目 看起来确实也没啥规律但是先写一下,写出来之后就有规律了,在纸上花花看看,这个是属于比较简单的找规律题目,前些天遇到了一个需要用前三项来确定下一项的题,那时候没做出来.唉,还是应该先写一个稳稳地大数超时错答案,然后从中开始寻找答案之间的规律.

附上代码


#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n%4==2)
printf("yes\n");
else
printf("no\n");
}
}


posted @ 2015-12-01 12:05  X-POWER  阅读(175)  评论(0编辑  收藏  举报