斐波那契数列的一种计算方法
来源:互联网 发布:jre for windows.exe 编辑:程序博客网 时间:2024/06/14 10:43
#include <cstdio>#include <map>using namespace std;map<int, int> m;const int md = 19999997;//需要模的数long long f(const int x) { if(x <= 2) return x ? 1 : 0; if(m.count(x)) return m[x]; const int k = x >> 1; const long long a = f(k); const long long b = f(k + 1); if(x & 1) return m[x] = (a * a + b * b) % md; else return m[x] = a * (b + b - a + md) % md;}int main() { int n; scanf("%d", &n); printf("%d\n", int(f(n + 1))); return 0;}
0 0
- 斐波那契数列的一种计算方法
- UVA 11582 巨大数的斐波那契数列 (大数取模,幂取模,模的计算方法)
- 斐波那契数列-switch很有意思的一种写法
- 使用一种非常不优雅的方式解决斐波那契数列
- [ACM]斐波那契数列对应的奇偶数列
- 斐波那契数列数列的实现
- 有趣的斐波那契数列
- 斐波那契数列的解法?
- 斐波那契数列的应用
- 斐波那契数列的打印
- 斐波那契数列的神奇
- 斐波那契数列的
- 斐波那契数列的性质
- 斐波那契数列的计算
- 斐波那契数列的研究
- 新的斐波那契数列
- 斐波那契数列的计算
- 斐波那契数列的实现
- 【链表5】两个链表的第一个公共结点
- 剑指offer-算法题练习:part17 反转链表
- opencv 资料备份及机器学习
- Oracle 表和表数据恢复
- 梯度下降与线性回归--《机器学习》课程学习笔记
- 斐波那契数列的一种计算方法
- C/C++中结构体占用内存大小的计算方法
- iOS-Main-(RAC演练)-订阅和发送信号
- 最大子序列和问题
- JSP页面间传递参数方法介绍
- 忘了初心
- 文件共享服务nfs-samba
- [Leetcode]330. Patching Array
- HDU 4612 Warm up(无向图强连通分量缩点建树)