fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int m = in.nextInt();
  11. int n = in.nextInt();
  12. long[][] a = new long[m][n];
  13. a[m-1][0] = 1;
  14. for(int i = m-1; i >= 0; i--) {
  15. for(int j = 0; j < n; j++) {
  16. if(i == m-1 && j == 0) continue;
  17. a[i][j] = (i < m-1 ? a[i+1][j] : 0) + (j > 0 ? a[i][j-1] : 0);
  18. }
  19. }
  20. System.out.print(a[0][n-1]);
  21. }
  22. }
Success #stdin #stdout 0.06s 2184192KB
stdin
10 10
stdout
48620