Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int combination(long long x, long long y) {
  5. if (y == x) return 1;
  6. else if (y == 1) return x;
  7. else return combination(x - 1, y - 1) + combination(x - 1, y);
  8. }
  9. int main()
  10. {
  11. int t; cin >> t;
  12. while (t--) {
  13. int x, y;
  14. cin >> y >> x;
  15. long long ans = combination(x, y);
  16. cout << ans << "\n";
  17. }
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement