Skip to content

Commit 794e389

Browse files
committed
[Probability] baekjoon-13251
1 parent 0074b8c commit 794e389

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

Diff for: README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@
7272
| 01 | | [Baekjoon-11050 이항 계수 1](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11050) | |
7373
| 02 | | [Baekjoon-11051 이항 계수 2](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P11051) | DP |
7474
| 03 | | [Baekjoon-1010 다리 놓기](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P1010) | DP |
75-
| 04 | ⭐️ | [Baekjoon-1256 사전](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P1256) | |
75+
| 04 | ⭐️ | [Baekjoon-1256 사전](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Combination/P1256) | |
76+
77+
### Probability
78+
79+
| # || Problem | Note |
80+
| :-: | :----: | :------------------------------------------------------------------------------------------------------------------ | :------------------------ |
81+
| 01 | | [Baekjoon-13251 조약돌 꺼내기](https://github.com/Seogeurim/Algorithm-practice/blob/master/src/Probability/P13251) | |

Diff for: src/Probability/P13251/Main.java

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package Probability.P13251;
2+
3+
import java.io.BufferedReader;
4+
import java.io.FileInputStream;
5+
import java.io.InputStreamReader;
6+
import java.util.StringTokenizer;
7+
8+
public class Main {
9+
10+
static int N = 0, M, K;
11+
static int[] colors;
12+
static double ans = 0;
13+
14+
public static void main(String[] args) throws Exception {
15+
System.setIn(new FileInputStream("src/Probability/P13251/input.txt"));
16+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
17+
18+
M = Integer.parseInt(br.readLine());
19+
20+
colors = new int[M];
21+
StringTokenizer st = new StringTokenizer(br.readLine());
22+
for (int i = 0; i < M; i++) {
23+
colors[i] = Integer.parseInt(st.nextToken());
24+
N += colors[i];
25+
}
26+
27+
K = Integer.parseInt(br.readLine());
28+
29+
for (int i = 0; i < M; i++) {
30+
double colorPro = 1;
31+
for (int j = 0; j < K; j++) {
32+
colorPro *= (double) (colors[i] - j) / (N - j);
33+
}
34+
ans += colorPro;
35+
}
36+
37+
System.out.println(ans);
38+
}
39+
}

Diff for: src/Probability/P13251/input.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
13
3+
8

0 commit comments

Comments
 (0)