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
-------------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#define N 1000001
int ans[N]; int main()
{
int i; int n;
memset(ans, 0, sizeof(ans));
ans[0] = 7 % 3;
ans[1] = 11 % 3;
for (i = 2; i <= N; i++)
ans[i] = (ans[i - 1] + ans[i - 2]) % 3;
while (scanf("%d", &n) != EOF)
{
if (ans[n] == 0)
printf("yes\n");
else
printf("no\n");
}
return 0;
}

  

ACM1021:Fibonacci Again的更多相关文章

  1. 算法系列:Fibonacci

    Copyright © 1900-2016, NORYES, All Rights Reserved. http://www.cnblogs.com/noryes/ 欢迎转载,请保留此版权声明. -- ...

  2. lintcode:Fibonacci 斐波纳契数列

    题目: 斐波纳契数列 查找斐波纳契数列中第 N 个数. 所谓的斐波纳契数列是指: 前2个数是 0 和 1 . 第 i 个数是第 i-1 个数和第i-2 个数的和. 斐波纳契数列的前10个数字是: 0, ...

  3. POJ3070:Fibonacci——题解

    http://poj.org/problem?id=3070 题目大意:求Fibonacci数列第n项,对10000取模. 矩阵乘法板子题……实在不知道写什么了. #include<iostre ...

  4. 九度OJ 1092:Fibonacci (递归)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1923 解决:1378 题目描述: The Fibonacci Numbers{0,1,1,2,3,5,8,13,21,34,55...} ...

  5. 蓝桥杯-入门训练 :Fibonacci数列

    问题描述 Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1.当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少. 输入格式 输入包含一个整数n. ...

  6. 小总结:fibonacci数的产生

    我写的一个固定的函数来嘞: ]={,}; void f() { ;i<;i++) { fib[i]=fib[i-]+fib[i-]; } } 1,1,2,3,5,8,13,21,34,55,.. ...

  7. LintCode:Fibonacci

    C++ class Solution{ public: /** * @param n: an integer * @return an integer f(n) */ int fibonacci(in ...

  8. Codeforces Gym101205D:Fibonacci Words(KMP+递推)

    Gym 101205D 题意:f[0] = "0", f[1] = "1",接下来f[i] = f[i-1] + f[i-2],相当于字符串拼接.然后给出一个n ...

  9. Codechef:Fibonacci Number/FN——求通项+二次剩余+bsgs

    题意 定义 $F_n$ 为 $$F_n = \left\{\begin{matrix}0, n=0\\ 1, n=1 \\F_{n-1} + F_{n-2}, n > 1\end{matrix} ...

随机推荐

  1. 大数据实时计算工程师/Hadoop工程师/数据分析师职业路线图

    http://edu.51cto.com/roadmap/view/id-29.html http://my.oschina.net/infiniteSpace/blog/308401 大数据实时计算 ...

  2. 测试你的 In-app Billing 程序

    测试你的 In-app Billing 程序 为了保证 In-app Billing 可以在你程序中正常使用,你应该在把应用程序发布到Google Play之前进行测试.早期的测试有助于确保用户对于你 ...

  3. VS2013 添加 ILDasm

    1.找到ILDasm.exe文件: 打开C:\Program Files\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools 2.vs外部工具添加 工 ...

  4. Office Online Server 2016 部署和配置

    Office Online Server 2016 部署和配置https://wenku.baidu.com/view/65faf8de846a561252d380eb6294dd88d1d23d45 ...

  5. August 17th 2017 Week 33rd Thursday

    Fate is responsible for shuffling, but the game of cards is our own! 命运负责洗牌,但是玩牌的是我们自己! Today, I upd ...

  6. [BZOJ 1033][ZJOI2008]杀蚂蚁antbuster

    1033: [ZJOI2008]杀蚂蚁antbuster Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1200  Solved: 507[Submi ...

  7. opencv python3.6安装和测试

    安装: 命令行  pip install D:\python3.6.1\Scriptsopencv_python-3.2.0-cp36-cp36m-win_amd64.whl 测试代码: import ...

  8. 原生JS实现轮播图的效果

    原生JS实现轮播图的效果: 只要缕清了全局变量index的作用,这个轮播图也就比较容易实现了:另外,为了实现轮这个效果,有几处clearInterval()必须写上.废话不多说,直接上代码,修复了几个 ...

  9. 随手练——LintCode 433 - 小岛数量

    LintCode 433: https://www.lintcode.com/problem/number-of-islands/description LintCode 434: https://w ...

  10. 3、Spring Cloud - Eureka(构建服务端/客户端)

    3.1.Eureka简介 3.1.1.什么是 Eureka 和Consul.Zookeeper 类似, Eureka 是一个用于服务注册和发现的组件,最开始主要应用 于亚马逊公司旗下的云计算服务平台 ...