python 笔记
来源:互联网 发布:有道云笔记 ubuntu版 编辑:程序博客网 时间:2024/06/15 18:49
杭电acm 1005 python 实现:
A number sequence is defined as follows:
f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.
Given A, B, and n, you are to calculate the value of f(n).
递归是最简单的解决方法;
def numberswquene(a,b,n): if(n==2 or n==1): return 1; else: return (a*numberswquene(a,b,n-1)+b*numberswquene(a,b,n-2))%7; var = numberswquene(1,2,10);print var;
0 0
- Python笔记
- python笔记
- python笔记
- python笔记
- python笔记
- PYTHON笔记
- python笔记
- python笔记
- python笔记
- Python笔记
- Python笔记
- Python笔记
- PYTHON笔记
- Python笔记
- python笔记-------------
- python笔记
- Python笔记
- python 笔记
- 矩阵快速幂+二分法
- [Elasticsearch] 聚合的测试数据
- Linux 操作命令
- 高级指针
- Android 图片三级缓存机制工具类封装
- python 笔记
- 将所有的"..."字符串替换成_T("...")
- Android 开发工程师招聘要求
- Android植物大战僵尸教程学习总结(四)拓展
- 网卡如何发送和接收数据包
- Android 流式布局实现方法
- Android 自定义控件 优雅实现元素间的分割线 (支持3.0以下)
- PropertyResolver
- Android使用Path自定义波浪加载View