15hd_oj title--fibonacci Again

Source: Internet
Author: User

/*
* 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 ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.