Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 30227    Accepted Submission(s): 14685

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
 
Author
Leojay
 
 #include <stdio.h>

 int main()
{
int f[];
int n;
while(scanf("%d",&n)!=EOF)
{
int i,xh;
f[]=%;
f[]=%;
for(i=;i<;i++)
{
f[i]=(f[i-]+f[i-])%;
if(f[i]==&&f[i-]==)
break;
}
xh=i-;
n=n%xh;
if(f[n]==)
printf("yes\n");
else
printf("no\n");
}
return ;
}

思路详见hdu_1005  这两题类似

 

hdu_1021_Fibonacci Again_201310232237的更多相关文章

随机推荐

  1. null, undefined,"",0,false是什么关系?

    null本质上和0,"",false是一类东西,它们都表示一种数据类型的非值.正如0表示数字类型的非值,""表示字符类型的非值一样,null表示完全空的对象,即 ...

  2. Akka源码分析-官方文档说明

    如果有小伙伴在看官方文档的时候,发现有些自相矛盾的地方,不要怀疑,可能是官方文档写错了或写的不清楚,毕竟它只能是把大部分情况描述清楚.开源代码一直在更新,官方文档有没有更新就不知道了,特别是那些官方不 ...

  3. CF 351A - Jeff and Rounding DP

    http://codeforces.com/problemset/problem/351/C 题意:有2*n个浮点数a1,a2,a3...a2*n,把他们分成n队,对于每对<A,B>,对A ...

  4. html基础代码演示2

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  5. linux对比两个文件的差异

    在项目维护阶段,经常会对垃圾文件进行清理.比如没有在数据库中的文件进行删除,这个时候最好的选择就是使用shell命令了:废话不多说直接上代码: 1.首先准备好从数据表导出来的数据,方法随意 2.在服务 ...

  6. webstorm中配置过visualsvn,后面做更改要更换authentication realm的解决办法

    找这个找了好久,一直改不过来,终于找到了解决办法 首先,在提交代码时提示: 但是我的authentication realm已经时这个了,并且账号和密码也改了,所以要更改authentication ...

  7. day08-字符编码

    目录 计算机基础 启动应用程序 写文本的流程 Python解释器执行文件的原理 Python解释器与文本编辑器的区别 字符编码 字符编码发生在哪三个阶段 字符编码发展史与分类 总结 Python2与P ...

  8. id 转 entity

    object 是 entity原始的类 要使用id转化成entity要先将id.getobject 然后将这个值 (entity)转化成entity entity ent =id.getentity& ...

  9. 配置tfs2017的agent

    tfs支持四种验证方式,分别是:PAT.Negotiate.Integrated.Alternate 我们使用Negotiate方式 首先,登录tfs服务器,设置iis的身份验证  添加一个Negot ...

  10. table头部固定,内容滚动

    可以设置两个table,th,td得设置宽度:     <table>       <thead>          <tr><th></th&g ...