-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1161FactorialSum.java
More file actions
59 lines (53 loc) · 1.32 KB
/
URI1161FactorialSum.java
File metadata and controls
59 lines (53 loc) · 1.32 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1161">Factorial
* Sum</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1161FactorialSum {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
static final long[] FACTORIALS = {
1,
1,
2,
6,
24,
120,
720,
5040,
40320,
362880,
3628800,
39916800,
479001600,
6227020800L,
87178291200L,
1307674368000L,
20922789888000L,
355687428096000L,
6402373705728000L,
121645100408832000L,
2432902008176640000L
};
public static void main(String[] args) throws IOException {
String l;
String[] P;
while ((l = read()) != null) {
P = l.split("\\s");
out.println(FACTORIALS[toInt(P[0])] + FACTORIALS[toInt(P[1])]);
}
out.close();
}
private static String read() throws IOException {
return in.readLine();
}
private static int toInt(String s) {
return Integer.parseInt(s);
}
}