Skip to content

Commit 19b8b2d

Browse files
authored
Merge pull request #93 from AlgorithmWithGod/lkhyun
[20250212] BOJ / 골드4 / 주사위 게임 / 이강현
2 parents 3cd0fd1 + 5e79063 commit 19b8b2d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```java
2+
import java.io.*;
3+
public class Main{
4+
public static void main(String[] args) throws Exception{
5+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
7+
int N = Integer.parseInt(br.readLine());
8+
9+
double[] expectation = new double[N+1];
10+
11+
for(int i=1;i<=N;i++){
12+
for(int k=1;k<=6;k++){
13+
if(i-k >=0){
14+
expectation[i] += expectation[i-k];
15+
}
16+
}
17+
expectation[i] = 1+(expectation[i]/6);
18+
}
19+
bw.write(expectation[N]+"");
20+
bw.flush();
21+
}
22+
}
23+
```

0 commit comments

Comments
 (0)