博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于斐波那契数列的一些恒等式 模板 牛客OI测试赛 A 斐波拉契
阅读量:7049 次
发布时间:2019-06-28

本文共 839 字,大约阅读时间需要 2 分钟。

 

牛客A 斐波拉契

链接:

来源:牛客网

设f[i]表示斐波那契数论的第i项
f[1]=1,f[2] =1,f[i] = f[i - 1] + f[i - 2]
给定一个n

输入描述:

一个整数n

输出描述:

一个整数,表示答案

示例1

输入

4

输出

1

备注:

分析:第六个恒等式

AC代码:

#include #include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ls (r<<1)#define rs (r<<1|1)#define debug(a) cout << #a << " " << a << endlusing namespace std;typedef long long ll;const ll maxn = 1e3 + 10;const double eps = 1e-8;const ll mod = 1e9 + 7;const ll inf = 1e9;const double pi = acos(-1.0);int main() { std::ios::sync_with_stdio(false); string s; cin >> s; ll n = s[s.length()-1] - '0'; if(n&1) { cout << -1 << endl; } else { cout << 1 << endl; } return 0;}

  

转载于:https://www.cnblogs.com/l609929321/p/9559119.html

你可能感兴趣的文章
贪心算法
查看>>
数据流图的画法
查看>>
[SAP ABAP开发技术总结]业务对象和BAPI
查看>>
Win8应用开发 入门篇(三) UX交互导航模式
查看>>
基于Redis的开源分布式服务Codis
查看>>
Linux Shell Scripting Tutorial (LSST) v2.0
查看>>
[控件] CircleView
查看>>
jbpm入门样例
查看>>
在ubuntu下关闭笔记本触摸板
查看>>
PowerPoint在线浏览的几个方案
查看>>
CentOS6.5系统挂载NTFS分区的移动硬盘
查看>>
很具体GC学习笔记
查看>>
【三石jQuery视频教程】03.创建垂直时间表(Timeline)
查看>>
HTML5系列:HTML5本地存储
查看>>
android完全退出应用程序
查看>>
Linux中cp和scp命令的使用方法
查看>>
Big Data Security Part One: Introducing PacketPig
查看>>
git入门-分支
查看>>
【转】win7与ubuntu双系统,删除ubuntu后,启动错误error:no such partition grub rescue的修复--不错...
查看>>
PHP-深入理解Opcode缓存
查看>>