/*
* Copyright (c) 2014, Computer College, Yantai University
* All rights reserved.
* File name: test.cpp
* Author: Li Xiaokei
* Date of Completion: May 24, 2015
* Version Number: v1.0
*
* Problem Description:
* Input Description:
* Program output:
*/
Problem Description There are another kind of Fibonacci numbers:f (0) = 7, f (1) = one, 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
Code:
#include <iostream>
using namespace std;
int main ()
{
long A;
while (Cin>>a)
{
if (a%8==2| | a%8==6)
cout<< "yes" <<endl;
else
cout<< "no" <<endl;
}
return 0;
}
Problem-solving ideas: This problem needs to find a good law, the law is 8 for a cycle, and when f (n) divided by 8 2 or 6, can be divisible by three, when found this rule, the topic is simple ....