Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 50863    Accepted Submission(s): 24079

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
 
一来想把数列所有值计算出来,发现数值增长实在太快,到几百的规模时longlong就溢出了。
然后自己推了一下发现,(a+b)%c==(a%c+b%c)%c,这应该是取模运算的性质。 然后就过了。
 
#include<iostream>
#include<cstdio>
using namespace std;
#define LL long long int f[];
int main()
{
f[]=;
f[]=;
int t=;
while(t<)
{
f[t]=(f[t-]+f[t-])%;
t++;
}
int n;
while(scanf("%d",&n)!=EOF)
{
if(f[n]==)
printf("yes\n");
else
printf("no\n");
}
return ;
}

最新文章

  1. z-index和transform
  2. 基于@AspectJ配置Spring AOP之一--转
  3. 与众不同 windows phone (51) - 8.1 新增控件: DatePickerFlyout, TimePickerFlyout
  4. [poj2104] K-th Number (主席树)
  5. 用于 ‘Suse‘ Linux 包管理的 Zypper 命令大全
  6. 学习总结 vs软件简单了解
  7. Java线程同步之一--AQS
  8. Centos7 时区的设置
  9. leetcode刷题七&lt;整数反转&gt;
  10. 【从零开始搭建自己的.NET Core Api框架】(二)搭建项目的整体架构
  11. Python学习笔记4基本数据类型续
  12. Python11 RabbitMQ Redis
  13. init: wait for &#39;/dev/block/bootdevice/by-name/cache&#39; timed out and took 5007ms【学习笔记】
  14. [日常] Go语言圣经--JSON习题2
  15. PowerDesigner 打印错误
  16. 剑指Offer——扑克牌顺子
  17. jQuar总结10:jQuery操作元素的属性
  18. PostgreSQL - invalid input syntax for type timestamp with time zone
  19. Linux中/etc/passwd 和 /etc/shadows 详解
  20. Unique Paths II (dp题)

热门文章

  1. vSphere,ESXi,vCenter之间的关系
  2. php高效获取数据分页
  3. nyoj 739 笨蛋的难题四
  4. CI框架下的get_instance() 函数
  5. ios21--xib例子
  6. 在mac下设置环境变量
  7. 杂项-Java:MyBatis
  8. 基于Spark和Tensorflow构建DCN模型进行CTR预测
  9. Geometry Shader 实现 Wireframe 绘制边线的Shader
  10. bzoj 2763: [JLOI2011]飞行路线【分层图+spfa】