Sicily 13062. SubDiagonal Paths
来源:互联网 发布:深圳网络诈骗被骗5万 编辑:程序博客网 时间:2024/05/22 06:22
13062. SubDiagonal Paths
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
You are to find all of the paths on the bottom diagonal of a n x n grid. The path must only go from lefttoright or bottomtotop. Given a dimension of the grid (ex. n = 4), specify the number of such paths (ex. solution = 14).
Input
The input consists of a single integer n, the dimension of the square grid, 1 <= n <= 30, on each line. A zero will indicate the end of the input and should not be processed.
Output
For each input n, you should output the number of paths, as described above, that exist in an nxn grid, one per line.
Sample Input
12340
Sample Output
12514
Problem Source
2014年每周一赛第十五场暨“指点传媒杯”第六届中山大学ICPC新手赛模拟赛
// Problem#: 13062// Submission#: 3412529// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <stdio.h>#include <iostream>#include <vector>#include <string>#include <stack>#include <iomanip>#include <algorithm>#include <queue>#include <functional>#include <map>#include <string.h>#include <math.h>#include <list>using namespace std;int main() { std::ios::sync_with_stdio(false); long long dp[35]; dp[0] = 1; dp[1] = 1; for (int i = 2; i <= 30; i++) { dp[i] = 0; for (int j = 0; j < i; j++) { dp[i] += dp[j] * dp[i - 1 - j]; } } while (1) { int pos; cin >> pos; if (pos == 0) break; cout << dp[pos] << endl; } return 0;}
0 0
- Sicily 13062. SubDiagonal Paths
- SOJ.SubDiagonal Paths
- Sicily 1015. Jill's Tour Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Sicily 1027
- sicily 1007
- sicily 1795
- sicily 1036
- Android 按两次返回键退出
- 高斯判别分析(GDA)和朴素贝叶斯(NB)
- Sicily 1092. Stars in Your Window
- svn之——linux下清除svn的用户名和密码
- Android如何实现TCP和UDP传输
- Sicily 13062. SubDiagonal Paths
- 详细记录python的range()函数用法
- Android高效加载大图、多图解决方案,有效避免程序OOM
- 使用XML实现悬浮的添加按钮
- C++ 虚函数表解析
- HDU 5188 zhx and contest(带限制条件的 01背包)
- Sicily 13061. Block Party
- 第八章 影响自动化实施的非技术因素
- 在CentOS上搭建PHP服务器环境