FibonacciAgain
Time Limit: 2000/1000 MS (Java/Others) MemoryLimit: 65536/32768 K (Java/Others)
Total Submission(s): 21563 Accepted Submission(s): 10360
Problem Description
There areanother kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2)(n>=2).
Input
Inputconsists of a sequence of lines, each containing an integer n. (n <1,000,000).
Output
Print theword "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
解题思路,从题目可以看出,if 3divided(被3整除),本题是找规律题,不难发现是4个一循环。
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n;
while(cin>>n)
{
if(n%4==2)
printf("yes\n");
else
printf("no\n");
}
return 0;
}