zoj 2284
View Code
1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 using namespace std; 5 6 long long yanghui[22][222] = {0}; 7 8 void init() 9 { 10 int row,column; 11 12 for(row = 1; row < 20; ++ row){ 13 yanghui[row][0] = 1; 14 for(column = 0; yanghui[row][column] > 0; ++column){ 15 for(int i = 0;i <= row; ++i){ 16 yanghui[row + 1][column + i] += yanghui[row][column]; 17 } 18 } 19 } 20 return ; 21 } 22 23 int main() 24 { 25 init(); 26 int n,k; 27 while(cin >> n >> k && (n || k)){ 28 printf("%lld\n",yanghui[n][k]); 29 } 30 return 0; 31 }