hdu 1021 Fibonacci Again

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 44959    Accepted Submission(s): 21451


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
 
Author
Leojay
 
Recommend
JGShining   |   We have carefully selected several similar problems for you:  1071 1032 1170 1028 1022 
 
简单的找规律,打表后发现每4个一次循环。
 
题意:按题意 F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2) 这个公式求值,判断这个F[n]是否是3的倍数,是输出yes,不是输出no。
 
附上代码:
 
 1 #include <cstdio>
 2 #include <iostream>
 3 using namespace std;
 4 int main()
 5 {
 6     int n;
 7     while(~scanf("%d",&n))
 8     {
 9         if((n-2)%4==0)
10             printf("yes
");
11         else
12             printf("no
");
13     }
14     return 0;
15 }
原文地址:https://www.cnblogs.com/pshw/p/4812442.html