zoukankan      html  css  js  c++  java
  • Fibonacci Again-hdu-1021

    Fibonacci Again

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 29168    Accepted Submission(s): 14126

    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<stdio.h>

    int main()

    {

        int f(int n);

        int n,m,i,j,k,t;

        while(scanf("%d",&n)!=EOF)

        {

         k=f(n);

         if(k%3==0)

         printf("yes ");

         else

         printf("no ");

        }

        return 0;

    }

    int f(int n)

    {

        int c;

        if(n==0)

        c=7;

        else if(n==1)

        c=11;

        else

        c=f((n-1))+f((n-2));

        return c;

    }//不能AC 错误 类型Runtime Error(STACK_OVERFLOW )。 (运行时错误,堆栈溢出)*/

    #include<stdio.h>

    int main()

    {

        int n;

        while(scanf("%d",&n)!=EOF)

        {

         if((n+2)%4==0)

         printf("yes ");

         else

         printf("no ");

        }

        return 0;

    }//由第一个程序可以 知道前10组数据的结果,然后找规律得出第二个程序。   通过本题,应该知道做题不能仅限于编程从解决方法找找答案,也可以从其他角度想一想,例如,找规律

    //当然,找规律是建立在知道答案的基础上,因此要把视野放开,可以先从结果出发,由果寻因。换个角度,会有更大的发现。

  • 相关阅读:
    云南9日游攻略
    移动端和边缘端的深度学习概述
    卷积、反卷积与膨胀卷积
    语义分割简述
    数据结构与算法----2总览
    python 中easydict库解析json文件
    python命令行传参解析(二)------ConfigParser
    plt.imshow与cv2.imshow显示颜色问题
    图卷积GCN
    十、mysql 数据类型
  • 原文地址:https://www.cnblogs.com/zhouhongweihpu/p/3217512.html
Copyright © 2011-2022 走看看