-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.java
39 lines (30 loc) Β· 1.05 KB
/
Main.java
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
package Probability.P13251;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static int N = 0, M, K;
static int[] colors;
static double ans = 0;
public static void main(String[] args) throws Exception {
System.setIn(new FileInputStream("src/Probability/P13251/input.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
M = Integer.parseInt(br.readLine());
colors = new int[M];
StringTokenizer st = new StringTokenizer(br.readLine());
for (int i = 0; i < M; i++) {
colors[i] = Integer.parseInt(st.nextToken());
N += colors[i];
}
K = Integer.parseInt(br.readLine());
for (int i = 0; i < M; i++) {
double colorPro = 1;
for (int j = 0; j < K; j++) {
colorPro *= (double) (colors[i] - j) / (N - j);
}
ans += colorPro;
}
System.out.println(ans);
}
}