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

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

  • 相关阅读:
    踩踩踩
    c语言可变参
    C++开发者都应该使用的10个C++11特性
    c++11 条件变量 生产者-消费者 并发线程
    c++11 线程
    C++ 虚函数表解析 继承
    坐标系
    C++ 容器:顺序性容器、关联式容器和容器适配器
    全面深入介绍C++字符串:string类
    做一个懒COCOS2D-X程序猿(一)停止手打所有cpp文件到android.mk
  • 原文地址:https://www.cnblogs.com/zhouhongweihpu/p/3217512.html
Copyright © 2011-2022 走看看