NEFU 20 穿过街道

来源:互联网 发布:手机小夜灯软件 编辑:程序博客网 时间:2024/06/10 04:37

穿过街道

Problem:20

Time Limit:1000ms

Memory Limit:65536K

Description

一个城市的街道布局如下:从最左下方走到最右上方,每次只能往上或往右走,一共有多少种走法? 

Input

输入很多行行数,每行1个数字代表n的值,当n=0时结束(2<=n<=15)

Output

输出对应每行n值的走法.

Sample Input

121050

Sample Output

26184756252

Hint

while(scanf("%d",&n)!=EOF&&n!=0){}

Source


#include <iostream>using namespace std;int main(){    int n;    long long a[20][20];    for(int i=0;i<20;i++)    {        a[0][i]=1;        a[i][0]=1;    }    for(int j=1;j<20;j++)        for(int k=1;k<20;k++)        a[j][k]=a[j-1][k]+a[j][k-1];        while(cin>>n&&n!=0)    cout <<a[n][n]<< endl;    return 0;}


Discuss

0 0