博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1021 Fibonacci Again
阅读量:4320 次
发布时间:2019-06-06

本文共 1058 字,大约阅读时间需要 3 分钟。

Fibonacci Again

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

Total Submission(s): 44959    Accepted Submission(s): 21451

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
 

 

Recommend
JGShining   |   We have carefully selected several similar problems for you:            
 
简单的找规律,打表后发现每4个一次循环。
 
题意:按题意 F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2) 这个公式求值,判断这个F[n]是否是3的倍数,是输出yes,不是输出no。
 
附上代码:
 
1 #include 
2 #include
3 using namespace std; 4 int main() 5 { 6 int n; 7 while(~scanf("%d",&n)) 8 { 9 if((n-2)%4==0)10 printf("yes\n");11 else12 printf("no\n");13 }14 return 0;15 }

 

转载于:https://www.cnblogs.com/pshw/p/4812442.html

你可能感兴趣的文章
虚拟基类的初始化
查看>>
C++中析构函数为什么要是虚函数
查看>>
【转】记录pytty用户名和密码
查看>>
Django Rest Framework 视图和路由
查看>>
不忘初心,方得始终 ,让我们一起学习成长,感谢有你!
查看>>
InputControls的应用
查看>>
20190312_浅谈go&java差异(一)
查看>>
软件工程博客---团队项目---个人设计4(算法流程图)
查看>>
数据结构3——数组、集合
查看>>
坚定信心
查看>>
C++中 <iso646.h>头文件
查看>>
spring cloud: Hystrix(六):feign的注解@FeignClient:fallbackFactory(类似于断容器)与fallback方法...
查看>>
CISCO 动态路由(OSPF)
查看>>
vue.js实现移动端长按事件,处理长按事件和click事件冲突,长按安卓机支持震动...
查看>>
个人开发—进度记录(十一)
查看>>
java中JVM的原理
查看>>
php这是一个随机打印输出字符串的例子
查看>>
前端的图片压缩image-compressor(可在图片上传前实现图片压缩)
查看>>
20165309 实验四 Android程序设计
查看>>
团队博客目录
查看>>