-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTotalPath.java
More file actions
36 lines (30 loc) · 1001 Bytes
/
Copy pathTotalPath.java
File metadata and controls
36 lines (30 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Created by MalhotR1 on 04/26/2017.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class TotalPath {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().trim());
for (int t = 0; t < T; t++) {
String[] in = br.readLine().trim().split(" ");
int a = Integer.parseInt(in[0]);
int b = Integer.parseInt(in[1]);
int max = Math.max(a,b) - 1;
int min = Math.min(a,b) - 1;
int total = max + min;
int prod = 1;
int prod2 = 1;
for (int i = max + 1; i <= total ; i++) {
prod *= i;
}
for (int i = 1; i <= min ; i++) {
prod2 *= i;
}
prod = prod / prod2;
System.out.println(prod);
}
}
}