全部博文(68)
分类: C/C++
2012-01-18 20:39:05
Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner.
How many routes are there through a 2020 grid?
答案:137846528820
类似于杨辉三角的解决方法:
#include
int main(void)
{
long long grid[21][21] = {{0L}};
int i=0,j=0;
for(i=0; i<21; i++)
grid[0][i]=grid[i][0]=1;
for(i=1; i<21; i++)
for(j=1; j<21; j++)
grid[i][j] = grid[i-1][j] + grid[i][j-1];
printf("The numbers of way is %lli\n", grid[20][20]);
return 0;
}