HOJ Computer Transformation
2015-11-21 21:53
369 查看
题目链接
Problem Description
A binary search tree is a binary tree with root k such that any node v reachable from its left has label (v)
Problem Description
A binary search tree is a binary tree with root k such that any node v reachable from its left has label (v)
#include <iostream> const int MAX = 1000 + 1; const int LENGTH = 300 + 10; int num[MAX][LENGTH]; int len[MAX]; using namespace std; int Initial() { int i,j; int temp; int carry; int digit; num[0][0] = 0; num[0][LENGTH] = 1; num[1][0] = 1; num[1][LENGTH] = 1; len[1] = 1; len[0] = 1; for(i = 2; i < MAX; i++) { carry = 0; for(j = 0; j < len[i - 1]; j++) { temp = num[i - 1][j] + 2 * num[i - 2][j] + carry; num[i][j] = temp % 10; carry = temp / 10; } while(carry){ num[i][j++] = carry % 10; carry /= 10; } len[i] = j; } return 0; } int print(int n){ for(int j = len[n - 1] - 1;j >= 0;j--) cout << num[n - 1][j]; cout << endl; return 0; } int main() { int n; Initial(); while(cin >> n) print(n); return 0; }
相关文章推荐
- 南大软院21天大神养成计划-第5天
- win7 ghost 安装串口驱动inf文件出现问题
- win 32 dll 编程demo
- Android自复制传播APP原理学习(翻译)
- HYSBZ 1036 【树链剖分】
- 【机房合作】SVN的安装问题
- Linxu笔记(10): 文件系统管理与简单命令
- 用ArrayList存储数据实现栈的功能(写着玩的)
- 设计模式功能概述(Design Patterns)
- linux基本操作
- MyEclipse 环境配置
- Hello,world,我是一位疯狂的高中生
- 关于limit_req和limit_conn的区别
- 服务与多线程-简单音乐播放器
- .NET Reflector 7.6.1.824安装及破解(刚试了,绝对能用)
- AS代码优化技巧
- Linxu笔记(9): ACL权限
- 18 款超酷的 HTML5 和 JavaScript 游戏引擎库
- HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
- kvm qemu pci passthough