Fibonacci Again
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 29168 Accepted Submission(s): 14126
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 f(int n);
int n,m,i,j,k,t;
while(scanf("%d",&n)!=EOF)
{
k=f(n);
if(k%3==0)
printf("yes ");
else
printf("no ");
}
return 0;
}
int f(int n)
{
int c;
if(n==0)
c=7;
else if(n==1)
c=11;
else
c=f((n-1))+f((n-2));
return c;
}//不能AC 错误 类型Runtime Error(STACK_OVERFLOW )。 (运行时错误,堆栈溢出)*/
#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if((n+2)%4==0)
printf("yes ");
else
printf("no ");
}
return 0;
}//由第一个程序可以 知道前10组数据的结果,然后找规律得出第二个程序。 通过本题,应该知道做题不能仅限于编程从解决方法找找答案,也可以从其他角度想一想,例如,找规律
//当然,找规律是建立在知道答案的基础上,因此要把视野放开,可以先从结果出发,由果寻因。换个角度,会有更大的发现。