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. web 前端:连接mysql中文乱码问题的解决办法

    当使用tomcat部署servlet连接时,总是出现各种原因的中文乱码问题.有的是因为mysql的默认字符集的问题,有的是客户端的字符配置问题. 现在对于这两种问题进行配置,来解决乱码. 服务器端(m ...

  2. t4 multiple output sample

    <#@ output extension=".js" #> <#@ template debug="false" hostspecific=& ...

  3. const 关键字及作用

    1.const 修饰一般常量,可以把变量变成常量 例如: int  num=10; num=100; printf(“num=%d\n”,num); 输出的来得值为:100: 但是如果const in ...

  4. [转]-Dmaven.multiModuleProjectDirectory system propery is not set. 解决方案 适用于myeclipes 和 eclipes

    eclipse中使用maven插件的时候,运行run as maven build的时候报错 -Dmaven.multiModuleProjectDirectory system propery is ...

  5. SVN空格问题的解决方法

    (注意:如果你的路径里有空格记得要在binpath的头尾用转义字符/"把整个个binpath框起来,D:\SVN\svnroot指svn资源库根目录) displayname指服务名称 de ...

  6. ORA-12154的原因

    一个很难想到的引起ORA-12154的原因         使用OracleClient.OracleConnection时(我连的是Oracle 9i,其他版本未知),如果你的执行目录太长或者有括号 ...

  7. 夺命雷公狗—express—1—express的配置方法和目录结构分析

  8. 夺命雷公狗---DEDECMS----8dedecms干掉首页和-文档页-栏目页的页面的广告

    我们首先来将首页生成静态页面,如下图所示: 成功后,如下显示: 如果成功后则在文件夹下多了一个index.html的文件.. 我们的首页静态页面是通过模版文件生成,所以我们只需要把模版文件的广告标签删 ...

  9. PTPX中的clock tree与LP design

    PTPX在加入CPF/UPF这样的文件后,可以分析multi-voltage,power-gating这样的设计. 针对某个power rail的cell,PTPX支持进行annotate. set_ ...

  10. Javascript与C#编码解码

    (一) Javascript与C#编码解码的对应关系 http://www.jb51.net/article/44062.htm 这篇文章主要是对JS与C#编码解码进行了详细的介绍,需要的朋友可以过来 ...