Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long factorial(int n) {
  6. long long fact = 1;
  7. for (int i=2; i<=n; ++i)
  8. fact *= i;
  9. return fact;
  10. }
  11.  
  12. int uniquePath(int m, int n) {
  13. int mx = max(m-1, n-1);
  14. int mn = min(m-1, n-1);
  15. long long dividend = 1;
  16. for (int i=1; i<=mn; ++i)
  17. dividend *= (mx+i);
  18. long long ret = dividend / factorial(mn);
  19. return (int)ret;
  20. }
  21.  
  22. int main() {
  23. cout << uniquePath(23,12) << "\n";
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement