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 ...
随机推荐
- 20155210 2016-2017-2《Java程序设计》课程总结
20155210 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 预备作业1:你期望的师生关系 预备作业2:做中学 预备作业3:虚拟机安装 第一周作业:教材 ...
- PGP的原理与使用
实验名称: PGP的原理与使用 姓名: 刘浩 20155307 任泓霖 20155319 班级: 1553 日期: 2017.10.16 一. 实验环境 Windows虚拟机下使用的是PKZIP2.0 ...
- U盘装系统流程_U启动
步骤 (已有装机U盘的前提下,没有则参考U启动制作U盘启动盘详细教程) (这里默认已设置了相关开机设置,若没设置则参考怎么用u盘装win7系统(推荐看)中步骤11-13) 按开机键后,不断按F12(有 ...
- 回顾RAC安装过程中对ASM的处理
1 首先建立好节点间共享的磁盘,要注意从各节点看到的磁盘的序号.名称一致. 2 通过某一个节点,对共享磁盘进行格式化. 3 在Grid Infrastructure 中, 有一个为OCR选择存储介质的 ...
- java Cannot resolve constructor 不能解析构造函数
这个报错是因为构造函数要求传入的变量或对象等,必须在调用时传入,否则就无法解析构造函数,这跟调用方法必须把参数传齐了一个道理
- 四、利用EnterpriseFrameWork快速开发基于WCF为中间件的三层结构系统
回<[开源]EnterpriseFrameWork框架系列文章索引> EnterpriseFrameWork框架实例源代码下载: 实例下载 本章内容与上一张<利用Enterprise ...
- TensorFlow深度学习实战---MNIST数字识别问题
1.滑动平均模型: 用途:用于控制变量的更新幅度,使得模型在训练初期参数更新较快,在接近最优值处参数更新较慢,幅度较小 方式:主要通过不断更新衰减率来控制变量的更新幅度. 衰减率计算公式 : deca ...
- 学习HTML 第五节.简单交互 加个按钮
学习HTML 第五节.简单交互 也许你和我一样,对页面排版的兴趣小于网页交互,那么我们就先略过一些章节,直接先学一下简单交互. 前面点击图片打开链接的网址,已经是最简单的交互方式了,复杂的方式则需要用 ...
- youtube视频下载和搬运的方法
youtube全球最大的视频网站, 全世界每天有三分之一的网民在youtube上观看视频, 可是大部分人不知道, 在这些网民有一小部分人是依靠youtube生存的, 他们上传视频到youtube, y ...
- http-equiv=mobile-agent说明
Meta声明的格式:<meta http-equiv=”mobile-agent” content=”format=[wml|xhtml|html5]; url=url”> 比如: < ...