https://vjudge.net/contest/67836#problem/A

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

时间复杂度:$O(10^6)$

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 1e6 + 10;
int Fib[maxn]; int main() {
Fib[0] = 7, Fib[1] = 11;
for(int i = 2; i < maxn; i ++)
Fib[i] = (Fib[i - 1] + Fib[i - 2]) % 3; //同余定理
int n;
while(~scanf("%d", &n)) {
if(Fib[n] % 3)
printf("no\n");
else
printf("yes\n");
}
return 0;
}

  

ZOJ 2060 A-Fibonacci Again的更多相关文章

  1. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  2. zoj 2060 Fibonacci Again(fibonacci数列规律、整除3的数学特性)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2060 题目描述: There are another kind ...

  3. [zoj 3774]Power of Fibonacci 数论(二次剩余 拓展欧几里得 等比数列求和)

    Power of Fibonacci Time Limit: 5 Seconds      Memory Limit: 65536 KB In mathematics, Fibonacci numbe ...

  4. zoj 1828 Fibonacci Numbers

    A Fibonacci sequence is calculated by adding the previous two members of the sequence, with the firs ...

  5. ZOJ 3774 Fibonacci的K次方和

    In mathematics, Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers of the f ...

  6. ZOJ 2672 Fibonacci Subsequence(动态规划+hash)

    题意:在给定的数组里,寻找一个最长的序列,满足ai-2+ai-1=ai.并输出这个序列. 很容易想到一个DP方程 dp[i][j]=max(dp[k][i])+1. (a[k]+a[i]==a[j], ...

  7. zoj Fibonacci Numbers ( java , 简单 ,大数)

    题目 //f(1) = 1, f(2) = 1, f(n > 2) = f(n - 1) + f(n - 2) import java.io.*; import java.util.*; imp ...

  8. ZOJ 3702 Fibonacci

    解题思路: 找规律,不难的,打表 坑的地方在于题目限定条件 and the seed value for G(1) is a random integer t, (t>=1) 虽然都用粗体表示出 ...

  9. Fibonacci数列的幂和 zoj 3774

    题目大意: 求斐波那契数列前n项的k次幂和  Mod 1000000009.    n<=1e18, k<=1e5 这题的k比较大,所以不能用矩阵乘法来递推.学到了新姿势...  http ...

随机推荐

  1. Python学习笔记——常用的内置函数

    一.yield def EricReadlines(): seek = 0 while True: with open('D:/temp.txt','r') as f: f.seek(seek) da ...

  2. python学习笔记(一):基础知识点

    defaultdict函数将所有值初始化为指定类型 from collections import defaultdict a = defaultdict(int) a[0] '' python按照引 ...

  3. SQL学习笔记:函数

    SQL函数 AVG select AVG(col) AS avgvalue from tablename select col2 from tablename where col1>(selec ...

  4. Spring Cloud学习入门路线方案

    Spring Cloud 为开发者提供了在分布式系统(如配置管理.服务发现.断路器.智能路由.微代理.控制总线.一次性Token.全局锁.决策竞选.分布式会话和集群状态)操作的开发工具.本Spring ...

  5. React with webpack

    //entry.js require("!style!css!./style.css"); require("./hello.jsx"); // documen ...

  6. 20155202 《Java程序设计》实验一(Java开发环境的熟悉)实验报告

    20155202 <Java程序设计>实验一(Java开发环境的熟悉)实验报告 一.实验内容及步骤 使用JDK编译.运行简单的java程序 命令行下的程序开发 一(新建文件夹): 打开wi ...

  7. 20155206 《Java程序设计》实验三实验报告

    20155206 <Java程序设计>实验三实验报告 实验内容 Java敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 实验步骤 提交一: 提交二: 提交三: 提交四:

  8. JS中的eval函数

           最近开始慢慢学习前端的脚本了,上次碰到了一个问题,需要通过一个对象的属性名称来获得这个对象这个属性的值.如果在C#中,那么直接通过反射就可以了.而在js中,也有类似的函数,那就是eval ...

  9. 安装centos minimal 版本后安装mysql详细过程(linux)

    本文内容参考自:http://www.centoscn.com/mysql/2014/1211/4290.html PS:Yum(全称为 Yellow dog Updater, Modified)是一 ...

  10. android 签名相关

    查看keystorekeytool -list -v -keystore debug.keystoreapk签名不带别名 apksigner sign --ks debug.keystore test ...