• Fibonacci Again 分类: HDU 2015-06-26 11:05 13人阅读 评论(0) 收藏


    Fibonacci Again
    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 43539 Accepted Submission(s): 20797

    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

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    
    using namespace std;
    
    const int Max=1100000;
    int Arr[Max];
    int main()
    {
        memset(Arr,0,sizeof(Arr));
        Arr[0]=1;
        Arr[1]=2;
        for(int i=2;i<Max;i++)
        {
            Arr[i]=(Arr[i-1]+Arr[i-2])%3;
        }
        int n;
        while(~scanf("%d",&n))
        {
            if(!Arr[n])
            {
                printf("yes
    ");
            }
            else
            {
                printf("no
    ");
            }
    
        }
        return 0;
    }
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    esp32-智能语音-mp3(sdcard)
    esp32-智能语音-ADF_PATH
    esp32-智能语音-wifi
    esp32-智能语音-led驱动
    esp32-智能语音-设计硬件问题
    技小新学习
    TVS管和ESD管
    电源IC
    天线2.4G阻抗匹配设计
    AD16建立集成库
  • 原文地址:https://www.cnblogs.com/juechen/p/4721983.html
Copyright © 2020-2023  润新知