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. Coursera Algorithms Programming Assignment 5: Kd-Trees (98分)

    题目地址:http://coursera.cs.princeton.edu/algs4/assignments/kdtree.html 分析: Brute-force implementation. ...

  2. putty+Xmanager登陆Linux,实现图形界面操作.

  3. P3390矩阵快速幂

    题目背景 矩阵快速幂 题目描述 给定n*n的矩阵A,求A^k 输入输出格式 输入格式: 第一行,n,k 第2至n+1行,每行n个数,第i+1行第j个数表示矩阵第i行第j列的元素 输出格式: 输出A^k ...

  4. [App Store Connect帮助]三、管理 App 和版本(2.4)输入 App 信息:提供加密出口合规证明文稿

    上传至 App Store Connect 的 App 被上传至位于美国的 Apple 服务器.如果您提交 App 的目的是为了在 App Store 上分发您的 App 或通过美国或加拿大的境外 T ...

  5. [Swift通天遁地]七、数据与安全-(8)创建普通PDF文档和加密PDF文档

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  6. 前端性能优化---减少http请求数量和减少请求资源的大小

    减少http请求数量:就是资源的合并 减少http请求大小:就是资源的压缩   一.资源合并的原理:   资源不合并的缺点: 1.文件和文件之间有插入请求----请求a.js,b.js,c.js(三行 ...

  7. ACM_黯然销魂?

    黯然销魂? Time Limit: 2000/1000ms (Java/Others) Problem Description: 发神集训表现出色,决定要送他鸡翅,但是锴神决定不让他那么容易拿到,所以 ...

  8. 网上流行的学生选课相关的50个常用sql语句

    学生表 Student(S#,Sname,Sage,Ssex) 教师表 Teacher(T#,Tname) 课程表 Course(C#,Cname,T#) 学生成绩表 SC(S#,C#,score) ...

  9. JS——冒泡案例

    模态框 1.因为a链接和和顶级document都注册了单击事件,所以要阻止a链接向父级盒子冒泡,不然又会从document的单击事件走一遍 2.在document的单击事件中,只需要判断触发事件的目标 ...

  10. 本地运行项目成功 ,但在服务器运行程序就会报Failed to establish a new connection: [Errno -2] Name or service not known

    equests.exceptions.ConnectionError: HTTPSConnectionPool(host=): Max retries exceeded with url: /appa ...