ZOJ 2060 A-Fibonacci Again
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的更多相关文章
- ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!
两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...
- zoj 2060 Fibonacci Again(fibonacci数列规律、整除3的数学特性)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2060 题目描述: There are another kind ...
- [zoj 3774]Power of Fibonacci 数论(二次剩余 拓展欧几里得 等比数列求和)
Power of Fibonacci Time Limit: 5 Seconds Memory Limit: 65536 KB In mathematics, Fibonacci numbe ...
- zoj 1828 Fibonacci Numbers
A Fibonacci sequence is calculated by adding the previous two members of the sequence, with the firs ...
- ZOJ 3774 Fibonacci的K次方和
In mathematics, Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers of the f ...
- 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], ...
- 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 ...
- ZOJ 3702 Fibonacci
解题思路: 找规律,不难的,打表 坑的地方在于题目限定条件 and the seed value for G(1) is a random integer t, (t>=1) 虽然都用粗体表示出 ...
- Fibonacci数列的幂和 zoj 3774
题目大意: 求斐波那契数列前n项的k次幂和 Mod 1000000009. n<=1e18, k<=1e5 这题的k比较大,所以不能用矩阵乘法来递推.学到了新姿势... http ...
随机推荐
- RUBY惯用方法(转)
RUBY惯用方法 目录 迭代 ||=赋值 程序入口 预设变量和特殊记号 inject 并行赋值 *的匹配 rescue简单用法 命名参数的默认值 精细duck typing控制 获取metaclass ...
- java虚拟机内存管理
1. java虚拟机内存如下 2. 运行时数据区 内存图分析:
- ubuntu下python在pycharm环境下安装setuptools和pip,和distutils.core
python安装好后,我们用pycharm安装所需的第三方模块时,出现“Python packaging tools not found. install packaging tools”点击安装输完 ...
- 以太坊入门-solidity环境搭建
本地remix-ide安装教程 一 开始安装前 准备以下软件 vs2015(主要会用到vc++的工具以及Windows sdk ||vs2017没试过,不过应该可以) vs下载安装以及解压地址: h ...
- 关于解决idea 输入法不跟随问题
网上查了很多方法 自己试验了一种方式 jdk版本采用的是 java version "1.8.0_191"Java(TM) SE Runtime Environment (bui ...
- .NET Core中使用RabbitMQ正确方式
.NET Core中使用RabbitMQ正确方式 首先甩官网:http://www.rabbitmq.com/ 然后是.NET Client链接:http://www.rabbitmq.com/dot ...
- (二)SpringBoot2.0基础篇- 静态资源的访问及Thymeleaf模板引擎的使用
一.描述 在应用系统开发的过程中,不可避免的需要使用静态资源(浏览器看的懂,他可以有变量,例:HTML页面,css样式文件,文本,属性文件,图片等): 并且SpringBoot内置了Thymeleaf ...
- unity游戏在ios11上不显示泰语解决办法
最近在开发中遇到unity游戏在ios11上不显示泰语的问题,全部显示为方框内一个问号. 通过搜索发现这是Unity的一个bug,在2017.3中修复了 但升级unity风险很大,所以我采用了该文中提 ...
- global中捕获异常
前言:由于现在日志非常重要,但是在哪里打写日志比较好呢,我选择的是在global中,把错误代码网上抛,而不是在底层写大量的try catch然后在catch中来写日志,每个catch中的写日志这样就会 ...
- ffmpeg 踩坑实录 近期使用总结(三)
一.背景介绍 将ffmpeg运用到项目上已经有一段时间了,趁现在有空赶紧记下来. 二.技术点总结 2.1 实现方式 项目里面主要运用的形式是,在java端,调用操作系统的方法,并执行切片命令. ...