• ___________一个简单题带来的启示____________________________


    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 n;
    while(scanf("%d",&n)!=EOF)
    {
    if(n%4==2)
    printf("yes ");
    else
    printf("no ");
    }
    }

    
    
  • 相关阅读:
    C# 数组
    一个遍历算法
    php csv导出
    linux 配置 crontab
    LINUX 配置SVN
    Linux chkconfig命令
    Linux 安装mysql+apache+php
    linux 安装samba
    linux安装软件的学习
    LINUX中简单的字符命令
  • 原文地址:https://www.cnblogs.com/A-FM/p/5009705.html
Copyright © 2020-2023  润新知