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