View Code
1 #include<stdio.h> 2 3 int main() 4 { 5 int m, n, k[11][11], t; 6 k[0][0] = 1; 7 for (m = 0; m < 11; m++) 8 { 9 k[m][1] = 1; 10 for (n = 2; n <= m; n++) 11 k[m][n] = k[m][n - 1] + k[m - n][n]; 12 while (n < 11) 13 k[m][n++] = k[m][m]; 14 } 15 scanf("%d", &t); 16 while (t--) 17 { 18 scanf("%d %d", &m, &n); 19 printf("%d\n", k[m][n]); 20 } 21 return 0; 22 }
当n>m时,f(m,n)=f(m,m)(其它的是空盘子),当n=1时f(m,n)=1(只有一个盘子),否则f(m,n)=f(m-1,n)+f(m-n,n)(所有盘子都有和有空的)