统计问题 2563
来源:互联网 发布:淘宝网首页打底衫 编辑:程序博客网 时间:2024/05/19 09:36
Problem Description
在一无限大的二维平面中,我们做如下假设:
1、 每次只能移动一格;
2、 不能向后走(假设你的目的地是“向上”,那么你可以向左走,可以向右走,也可以向上走,但是不可以向下走);
3、 走过的格子立即塌陷无法再走第二次;
求走n步不同的方案数(2种走法只要有一步不一样,即被认为是不同的方案)。
Input
首先给出一个正整数C,表示有C组测试数据
接下来的C行,每行包含一个整数n (n<=20),表示要走n步。
Output
请编程输出走n步的不同方案总数;
每组的输出占一行。
Sample Input
2
1
2
Sample Output
3
7
#include <iostream>int main(int argc, const char *argv[]){ __int64 result[20] = {3, 7}; for(int i = 2;i < 20;++ i) { result[i] = 2 * result[i - 1] + result[i - 2]; } int c = 0; std::cin >> c; while(c --) { int n = 0; std::cin >> n; std::cout << result[n - 1] << std::endl; } //system("pause"); return 0;}
0 0
- HDU 2563 统计问题
- HDU 2563 统计问题
- hdu 2563 统计问题
- hdu 2563 统计问题
- hdu 2563 统计问题
- hdu 2563 统计问题
- 统计问题 2563
- hdu-2563-统计问题
- hdu 2563 统计问题
- HDU 2563 统计问题
- hdu 2563 统计问题
- HDU - 2563 - 统计问题
- HDU-2563-统计问题
- HDU 2563 统计问题
- hdu 2563 统计问题
- 2563:统计问题
- hdu 2563 统计问题
- HDU 2563 统计问题
- 使用Node.js完成的第一个项目的实践总结
- CF DIV2 236E Strictly Positive Matrix(强连通)
- python教程专题资源免费下载整理合集收藏
- FFmpeg实时解码MediaRecorder视频流
- poj3264. RMQ模板题
- 统计问题 2563
- SpannableString 记录
- wo
- ExtJs
- ZZ-log@2014-03-17
- Android root权限破解分析
- [Python]获取当前时间
- 喷水装置(nyoj6)贪心算法
- iOS http get和post