fork download
  1. #include <stdio.h>
  2.  
  3. int com(int n, int r)
  4. {
  5. if(n==r || r==0)
  6. return 1;
  7. else
  8. return com(n-1, r-1)+com(n-1, r);
  9. }
  10.  
  11. int path(int x, int y)
  12. {
  13. if(x==0 && y==0)
  14. return 0;
  15. else
  16. return com(x+y,y);
  17. }
  18.  
  19. int main(void) {
  20. int x,y;
  21.  
  22. scanf("%d %d",&x,&y);
  23.  
  24. printf("%d\n",path(x,y));
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5316KB
stdin
2 2
stdout
6