hdu 1021 Fibonacci Again
2015-09-16 10:29
671 查看
Fibonacci Again
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 44959 Accepted Submission(s):
21451
[align=left]Problem Description[/align]
There are another kind of Fibonacci numbers: F(0) = 7,
F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
[align=left]Input[/align]
Input consists of a sequence of lines, each containing
an integer n. (n < 1,000,000).
[align=left]Output[/align]
Print the word "yes" if 3 divide evenly into
F(n).
Print the word "no" if not.
[align=left]Sample Input[/align]
0
1
2
3
4
5
[align=left]Sample Output[/align]
no
no
yes
no
no
no
[align=left]Author[/align]
Leojay
[align=left]Recommend[/align]
JGShining | We have carefully selected several
similar problems for you: 1071 1032 1170 1028 1022
简单的找规律,打表后发现每4个一次循环。
题意:按题意 F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2) 这个公式求值,判断这个F
是否是3的倍数,是输出yes,不是输出no。
附上代码:
#include <cstdio> #include <iostream> using namespace std; int main() { int n; while(~scanf("%d",&n)) { if((n-2)%4==0) printf("yes\n"); else printf("no\n"); } return 0; }
相关文章推荐
- Failed to install weixin11.apk on device 'emulator-5554': timeout
- The Beauty of Capturing Faces: Rating the Quality of Digital Portraits
- WIN7下运行hadoop程序报:Failed to locate the winutils binary in the hadoop binary path
- myibtais配置数据源属性生效优先级
- LeetCode Contains Duplicate
- 【投稿】友好的 ContainerView & AutoLayout 资料推荐
- LeetCode-Contains Duplicate II
- Rails 创建关联关系流程
- raid
- Aizu 2541 Magical Bridges
- leetcode笔记:Climbing Stairs(斐波那契数列问题)
- cairo-dock
- LeetCode----Climbing Stairs
- rails学习笔记:维护商品信息任务B
- 2015第37周二foxmail邮箱客户端迁移
- raise KeyError("Spider not found: {}".format(spider_name)) KeyError: 'Spider not found: novelspider'
- Aizu 2538 Stack Maze【记忆化搜索】
- Adb fail to restart! ADB server didn't ACK
- 【STL】STL之pair
- 怎么理解SpriteKit中的waitForDuration:withRange:方法