#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if((n+1)%4==3)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}

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

看到 Fibonacci Again 的第一眼就像用递归,感觉挺水的,敲代码,妥妥的超时了。  没办法,看看大神的,一致觉得水,水在那呢,看了之后发现,这题是找规律的,4为一个循环,1,2,3,4,分别是no,yes,no,no,所以就用(n+1)%4==3  >> no

ACM HDU 1021 Fibonacci Again的更多相关文章

  1. hdu 1021 Fibonacci Again(找规律)

    http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others ...

  2. hdu 1021 Fibonacci Again(变形的斐波那契)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Ot ...

  3. HDU 1021 Fibonacci Again【打表找规律】

    Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  4. HDU 1021 Fibonacci Again( 同余水 )

    链接:传送门 题意:现在给出 Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).问第 n 项能不能整除 ...

  5. HDU 1021 - Fibonacci Again

    找规律,分析让 F[N] 每一项对 3 取余的余数: 1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0 ......... 显然循环了 #inclu ...

  6. 同余定理简单应用 - poj2769 - hdu 1021 - hdu 2035

    同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+ ...

  7. 【HDU 1021】Fibonacci Again(找规律)

    BUPT2017 wintertraining(16) #5 A HDU - 1021 题意 There are another kind of Fibonacci numbers: F(0) = 7 ...

  8. hdu 4786 Fibonacci Tree (2013ACMICPC 成都站 F)

    http://acm.hdu.edu.cn/showproblem.php?pid=4786 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others) ...

  9. HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)

    HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的 ...

随机推荐

  1. Poj 2299 - Ultra-QuickSort 离散化,树状数组,逆序对

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 52306   Accepted: 19194 ...

  2. JAVA--线程wait()、lnotify()和notifyAll()方法

    join()方法是Thread类的一个方法,而wait().notify().notifyAll()是java.lang.Object类的方法,这意味着,任何一个Java对象(包括线程对象)都有wai ...

  3. Java集合类操作优化经验总结

    本文首先针对 Java 集合接口进行了一些介绍,并对这些接口的实现类进行详细描述,包括 LinkedList.ArrayList.Vector.Stack.Hashtable.HashMap.Weak ...

  4. mv、umask、chattr、lsattr命令

    mv命令行,即move 将文件移动到目录下 对文件或目录重命名 umask chattr 设置文件或目录的隐藏属性 lsattr显示文件或目录的隐藏属性 ls mv 1.txt aa ls cd aa ...

  5. Oracle数据库中将一个数据库中一张表的数据导入到另外一张表

    INSERT INTO DBTHNEW.L_MEMBER_ROLE_REL SELECT    *FROM    DBTH.L_MEMBER_ROLE_REL

  6. [置顶] 第二届微软CRM交流年会

    第二届微软CRM交流会将在12月14日举行,亲们要是感兴趣可以查看下面的活动详情.Jeff也是第一次参加这类活动,作为本次活动的嘉宾我为大家带来一个挺有意思的分享主题<Dynamics CRM ...

  7. 检测到有潜在危险的Request.Form值

    由于在.net中,Request时出现有HTML或Javascript等字符串时,系统会认为是危险性值.立马报出“从客户端 中检测到有潜在危险的Request.Form值”这样的错. 用encodeU ...

  8. Java-struts2的问题 java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

    缺commons-lang3-3.1.jar,添加之后就可以了

  9. [MySQL] MySQL的自己主动化安装部署

    有过MySQL运维的人应该都清楚,线上的MySQL一般都採用源代码编译,由于这样才干够依据企业的各自须要选择要编译的功能,尽管MySQL的源代码编译挺简单的,可是试想一下,假设你有几百台server同 ...

  10. Android开发优化之——对Bitmap的内存优化

    http://blog.csdn.net/arui319/article/details/7953690 在Android应用里,最耗费内存的就是图片资源.而且在Android系统中,读取位图Bitm ...