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\n");
}
else
{
printf("no\n");
} }
return 0;
}

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

Fibonacci Again 分类: HDU 2015-06-26 11:05 13人阅读 评论(0) 收藏的更多相关文章

  1. 百度编辑器UEditor ASP.NET示例Demo 分类: ASP.NET 2015-01-12 11:18 346人阅读 评论(0) 收藏

    在百度编辑器示例代码基础上进行了修改,封装成类库,只需简单配置即可使用. 完整demo下载 版权声明:本文为博主原创文章,未经博主允许不得转载.

  2. Case of the Zeros and Ones 分类: CF 2015-07-24 11:05 15人阅读 评论(0) 收藏

    A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...

  3. Least Common Ancestors 分类: ACM TYPE 2014-10-19 11:24 84人阅读 评论(0) 收藏

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  4. 二分图匹配(KM算法)n^4 分类: ACM TYPE 2014-10-04 11:36 88人阅读 评论(0) 收藏

    #include <iostream> #include<cstring> #include<cstdio> #include<cmath> #incl ...

  5. Segment Tree with Lazy 分类: ACM TYPE 2014-08-29 11:28 134人阅读 评论(0) 收藏

    #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; stru ...

  6. 8大排序算法图文讲解 分类: Brush Mode 2014-08-18 11:49 78人阅读 评论(0) 收藏

    排序算法可以分为内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存. 常见的内部排序算法有:插入排序.希尔排序. ...

  7. C语言之void类型及void指针 分类: C/C++ 2015-07-13 11:24 8人阅读 评论(0) 收藏

    原文网址:http://www.cnblogs.com/pengyingh/articles/2407267.html 1.概述 许多初学者对C/C 语言中的void及void指针类型不甚理解,因此在 ...

  8. 指向函数的指针 分类: C/C++ 2015-07-13 11:03 14人阅读 评论(0) 收藏

    原文网址:http://www.cnblogs.com/zxl2431/archive/2011/03/25/1995285.html 讲的很清楚,备份记录. (一) 用函数指针变量调用函数 可以用指 ...

  9. iOS调用相机,相册,上传头像 分类: ios技术 2015-04-14 11:23 256人阅读 评论(0) 收藏

    一.新建工程 二.拖控件,创建映射 三.在.h中加入delegate @interface ViewController : UIViewController 复制代码 四.实现按钮事件 -(IBAc ...

随机推荐

  1. SqlServer2008根据现有表,获取该表的分区创建脚本

    *============================================================== 名称: [GetMSSQLTableScript] 功能: 获取cust ...

  2. Lintcode: Rotate String

    Given a string and an offset, rotate string by offset. (rotate from left to right) Example Given &qu ...

  3. [摘录] 关于 java 并发包

    1.http://www.raychase.net/698 Java多线程发展简史

  4. Android Preview显示

    Android Studio的功能包含preview窗口, 可以查看布局(layout)的样式; 位置: app->src->main->res(资源)->layout(布局) ...

  5. 详细介绍dll文件是什么

     DLL是Dynamic Link Library的缩写,意为动态链接库.DLL文件一般被存放在C:WindowsSystem目录下.DLL是一个包含可由多个程序同时使用的代码和数据的库. 在Wind ...

  6. python2.7使用ansible

    升级python到2.7后 $ ansible 报错 Traceback (most recent call last): File "/usr/bin/ansible", lin ...

  7. C# 实现 单例模式

    http://blog.sina.com.cn/s/blog_75247c770100yxpb.html

  8. 为archlinux安装mplayer

    很简单的一条命令: pacman -S mplayer 安装完之后是字符界面的,所以你还需要一个图形前端: pacman -S gnome-mplayer

  9. ralink网卡驱动的下载地址集合

    linuxMT7612U11/7/2014v3.0.0.1http://cdn-cw.mediatek.com/Downloads/linux/MT7612U_DPO_LinuxSTA_3.0.0.1 ...

  10. OpenStack主机列表接口

    如之前讨论,openstack提供一套接口给运维管理平台,运维管理平台通过获取到的IP地址对主机进行监控. 接口名  请求地址  请求方法  请求cookie  请求头  返回值  返回值使用  登录 ...