fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #define MAX 31
  4. using namespace std;
  5.  
  6. int main() {
  7. int tests, n, m;
  8. long long c[MAX][MAX];
  9. memset(c, 0, sizeof(c));
  10. for(int i = 0; i < MAX; i++) c[i][0] = 1;
  11. for(int i = 0; i < MAX; i++)
  12. for(int j = 1; j <= MAX; j++)
  13. c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
  14. cin >> tests;
  15. while(tests--) {
  16. cin >> n >> m;
  17. cout << c[n][m - 1] << "\n";
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15232KB
stdin
6
2 1
7 2
3 1
5 4
3 2
9 2
stdout
1
7
1
10
3
9