ACM HDU 1021 Fibonacci Again
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if((n+1)%4==3)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
Print the word "no" if not.
0
1
2
3
4
5
no
no
yes
no
no
no
看到 Fibonacci Again 的第一眼就像用递归,感觉挺水的,敲代码,妥妥的超时了。 没办法,看看大神的,一致觉得水,水在那呢,看了之后发现,这题是找规律的,4为一个循环,1,2,3,4,分别是no,yes,no,no,所以就用(n+1)%4==3 >> no
ACM HDU 1021 Fibonacci Again的更多相关文章
- hdu 1021 Fibonacci Again(找规律)
http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others ...
- hdu 1021 Fibonacci Again(变形的斐波那契)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Ot ...
- HDU 1021 Fibonacci Again【打表找规律】
Fibonacci Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1021 Fibonacci Again( 同余水 )
链接:传送门 题意:现在给出 Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).问第 n 项能不能整除 ...
- HDU 1021 - Fibonacci Again
找规律,分析让 F[N] 每一项对 3 取余的余数: 1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0, 1,1,2,0, 2,2,1,0 ......... 显然循环了 #inclu ...
- 同余定理简单应用 - poj2769 - hdu 1021 - hdu 2035
同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+ ...
- 【HDU 1021】Fibonacci Again(找规律)
BUPT2017 wintertraining(16) #5 A HDU - 1021 题意 There are another kind of Fibonacci numbers: F(0) = 7 ...
- hdu 4786 Fibonacci Tree (2013ACMICPC 成都站 F)
http://acm.hdu.edu.cn/showproblem.php?pid=4786 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others) ...
- HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)
HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意: 求第n个斐波那契数的 ...
随机推荐
- [洛谷U871]building
题目来源:http://www.luogu.org/problem/show?pid=U871# [题目背景 Background] WOW是BLIZZARD公司开发的一款网络游戏,游戏的背景是处在一 ...
- Bzoj 1616: [Usaco2008 Mar]Cow Travelling游荡的奶牛 动态规划
1616: [Usaco2008 Mar]Cow Travelling游荡的奶牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1006 Solved: ...
- parseSdkContent failed Could not initialize class android.graphics.Typeface
Deleting ".android" is temporarily fixing the problem with me as after sometime it begins ...
- UILable自适应frame
UILabel *textlab = [[UILabel alloc]initWithFrame:CGRectMake(20, 10,ScrollView.frame.size.width - 40, ...
- FLASH轮播广告 在谷歌浏览器中不显示的解决办法(FLash轮播放广告在谷歌浏览器中无法显示处理方法)
在用PHPWEB模板的时候,碰到首页有一个FLASH轮播广告,在IE浏览器下可以正常显示播放,在谷歌浏览器中却显示不了,解决办法如下: 欢迎转载:http://blog.csdn.net/aminfo ...
- Android开发艺术探索(三)——View的事件体系
一.View基础知识 主要介绍内容有:View的位置参数.MotionEvent和TouchSlope对象.VelocityTracker.GestureDetector和Scroller对象 1.什 ...
- Android下的Linux指令集
Android目录结构 data app:用户安装的应用 data:应用的专属文件夹 system:系统的配置信息,注册表文件 anr:anr异常的记录信息 dev:devices的缩写 存放设备所对 ...
- NIO组件Selector调用实例
*对于nio的非阻塞I/O操作,使用Selector获取哪些I/O准备就绪,注册的SelectionKey集合记录关联的Channel这些信息.SelectionKey记录Channel对buffer ...
- IT工作中工资最高和增长最快的是什么
Staff在博客IT Jobs with the Highest Pay and Fastest Growth中画了个图说明IT工作中工资最高和增长最快的是什么.
- 理解CSS中的三种选择器>+~
1. p~ul p和ul有相同的父元素,选择出p元素之后的所有ul元素,其中,p和ul不一定是紧随,但是必须有相同的父元素 E+F 相邻兄弟选择器.选择匹配F的元素,且该元素位于 ...