http://ac.jobdu.com/problem.php?id=1408
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdio.h> 4 int mat[1001][1001]={0}; 5 int main() 6 { 7 int m,n; 8 9 int i,j; 10 for(i=0;i<=1000;i++) mat[0][i]=1; 11 for(i=0;i<=1000;i++) mat[i][0]=1; 12 for(i=1;i<=1000;i++){ 13 for(j=1;j<=1000;j++){ 14 if(i==1){ 15 mat[i][j]=mat[i-1][j]; 16 } else if (j==1) { 17 mat[i][j]=mat[i][j-1]; 18 } else { 19 mat[i][j] = (mat[i-1][j]+mat[i][j-1])%10009; 20 } 21 } 22 } 23 while(scanf("%d%d",&m,&n)!=EOF) 24 printf("%d\n",mat[m][n]); 25 }