HDOJ   1021    Fibonacci Again
2015-12-18 18:06
537 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1021
#include<stdio.h>
int main () {
int n;
while
(scanf("%d",&n) != EOF)
printf("%s\n",(n+2)%4?"no":"yes");
return
0;
}
看起来简单的题,
开始的时候用暴力求解TLE、
最后发现,都是要找规律的
感觉可以定义一个数组,对算出来的只进行存储
for(i=3;i<200;i++)
{
f[i]=(a*f[i-1]+b*f[i-2])%7;
if(f[i-1]==1&&f[i]==1)
break;
}
判断他们循环的周期....
#include<stdio.h>
int main () {
int n;
while
(scanf("%d",&n) != EOF)
printf("%s\n",(n+2)%4?"no":"yes");
return
0;
}
看起来简单的题,
开始的时候用暴力求解TLE、
最后发现,都是要找规律的
感觉可以定义一个数组,对算出来的只进行存储
for(i=3;i<200;i++)
{
f[i]=(a*f[i-1]+b*f[i-2])%7;
if(f[i-1]==1&&f[i]==1)
break;
}
判断他们循环的周期....
相关文章推荐
- pair和make_pair用法
- [转]strong,weak, retain, assign的区别
- macbook air 只安装win7系统
- 详解Paint的setShader(Shader shader)
- 如何解决SVN Commit failed (details follow): Access denied
- LeetCode 172:Factorial Trailing Zeroes
- Exmail 邮件系统维护备忘录
- 通过aidl实现挂断电话
- HDU 1789Doing Homework again 贪心
- iptables:应用防火墙规则:iptables-restore: line 18failed
- ORA-27603: Cell storage I/O error, I/O failed on disk ORA-27626: Exadata error:
- [BetterExplained]如何有效地记忆与学习
- [BetterExplained]为什么你应该(从现在开始就)写博客
- 我遇到的错误:“Linker command failed with exit code 1” 的解决方案
- openerp 不能发送email,请配置发件人的email地址或者别名
- MongoDB 3.0的Explain
- AEAI EM费用管理系统V1.0.2版本开源发布
- AEAI EM费用管理系统V1.0.2版本开源发布
- 画布
- quartus II 15.0 中解决仿真报错 Error: (vsim-19) Failed to access library 的问题