Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 50096    Accepted Submission(s): 23727

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

题目意思不难懂吧,,a[n]%3==0?“yes\n”:"no\n";,,可是数据高达1000000,,常规斐波那契数列到40的样子就超了,,不妨打表到40看看输出结果:

for(i=0;i<45;i++)

if(a[i]%3==0) printf("%d %d  yes\n",i,a[i]);

else   printf("%d %d  no\n",i,a[i]);

看看输出结果认真观察发现了没,, 在i=2, 6, 10,14,18,22,26,30,34,38的时候输出yes,,,

没错,,if(n%4==2) printf("yes\n);

这样连数组都不用开了,,代码就不用贴出来了吧,,核心规律等都已呈上;

最新文章

  1. ThreadLocal&lt;T&gt;的是否有设计问题
  2. python第一天 - dict
  3. OPENGLES 基础(一些链接和随笔)
  4. python中*args和**args的不同
  5. dt.jar设计时rt.jar运行时
  6. Entityframework批量删除
  7. 例题6-10 The Falling Leaves,UVA699
  8. Integer类型值相等或不等分析
  9. The Woman in Red Is Seen as a Threat by Other Wom
  10. [HeadFirst-JSPServlet学习笔记][第三章:实战MVC]
  11. Sightseeing Cows(最优比率环)
  12. HDU 3264 Open-air shopping malls ——(二分+圆交)
  13. Python并发编程之多线程使用
  14. windows环境搭建nginx
  15. 【深入分析Java Web技术内幕】1、深入Web请求过程知识点
  16. MySQL字符集不一致的解决办法总结
  17. Windows 登录用户的类型
  18. python模块安装报错大全
  19. python中从内部循环直接跳出多层循环
  20. 〖Linux〗Linux高级编程 - 进程间通信(Interprocess Communication)

热门文章

  1. Linux下用matplotlib画决策树
  2. TRUNCATE DELETE DROP 区别
  3. Windows API函数大全二
  4. jQuery选择器之子元素选择器
  5. 【学习笔记】深入理解js原型和闭包系列学习笔记——精华
  6. 自定义Toast的显示位置和显示内容
  7. rabbitmq的知识点
  8. 自欺欺人的使用 NSTimer 销毁
  9. apropos命令
  10. Android(java)学习笔记181:多媒体之图片画画板案例