HDU1715 大菲波数
来源:互联网 发布:淘宝袜子好评语50字 编辑:程序博客网 时间:2024/05/21 10:13
问题链接:HDU1715 大菲波数。
问题简述:参见上述链接。
问题分析:大数问题。为了避免重复计算,需要打表。
程序说明:(略)。
AC的C++语言程序如下:
/* HDU1715 大菲波数 */#include <iostream>#include <string>using namespace std;const int MAXN = 1000;string s[MAXN+1];void maketable(int n){ string a, b; s[1] = "1"; s[2] = "1"; for(int i=3; i<=n; i++) { a = "00" + s[i-2]; b = "0" + s[i-1]; int val, carry=0; for(int j=(int)a.length()-1, k=(int)b.length()-1; k>=0; j--, k--) { val = (a[j] - '0') + (b[k] - '0') + carry; carry = val / 10; b[k] = val % 10 + '0'; } if(b[0] == '0') b.erase(0, 1); s[i] = b; }}int main(){ int n, pi; maketable(MAXN); cin >> n; while(n--) { cin >> pi; cout << s[pi] << endl; } return 0;}
1 0
- hdu1715 ( 大菲波数 )
- HDU1715:大菲波数
- hdu1715 大菲波数
- HDU1715 大菲波数
- hdu1715 大菲波数
- hdu1715 大菲波数
- hdu1715 大菲波数
- HDU1715:大菲波数
- HDU1715 大菲波数
- hdu1715 大菲波数
- hdu1715 大菲波数(高精度)
- hdu1715大菲波数(压位)
- HDU1715 大菲波数 【大数】
- HDU1715 大菲波数 【C版本】
- hdu1715 大菲波数(高精度)
- hdu1715
- hdu1715
- 大菲波数(hdu1715,大数加法)
- 在没有好方法之前,坚持,成了暂时的别无选择。
- CSDN编辑器语法
- Python轻松入门-24 解包列表
- 后缀.do和.action
- Jenkins 学习
- HDU1715 大菲波数
- JVM学习之对象的创建
- 列表生成式笔记
- MFC中在picture control中显示图像的方法
- 草根程序员转型做项目管理走过的点点滴滴之_华为裁员感想
- (OK) how to compile the source code for Android-x86 (Android 7.1.1)
- 生成天地图覆盖图片的切片(2017.3.5)
- (OK) how to customize the kernel for your hardware for Android-x86
- python学习 高阶函数/map()/reduce()/filter()/sorted()