fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n ; int m ;
  8. cin>>n;cin>>m;
  9. int dp[n+m+1][n+1];
  10. for(int i = 0 ; i<=n+m;i++){
  11. for(int j = 0;j<=n;j++){
  12. if(i==j || j==0) {
  13. dp[i][j]=1;
  14. }
  15. else if(j>i || i==0){
  16. dp[i][j]=0;
  17. }
  18. else{
  19. dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
  20. }
  21.  
  22. }
  23. }
  24. cout<<dp[n+m][n];
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5324KB
stdin
5 2
stdout
21