HDU 1021 Fibonacci Again

Source: Internet
Author: User
Tags printf

Description

There is 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

Fibonacci General Judge Yes,no time to pay attention to whether you can find the law on the line.

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main ()
{
    int a[8];
    A[0] = 1;
    A[1] = 2;
    A[2] = 0;
    A[3] = 2;
    A[4] = 2;
    A[5] = 1;
    A[6] = 0;
    A[7] = 1;
    int n;
    while (Cin>>n)
    {
        if (a[n%8]==0)
            printf ("yes\n");
        else
            printf ("no\n");
    }
}
Related Article

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.