結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2019-12-06 11:09:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 795 ms / 5,000 ms |
コード長 | 635 bytes |
コンパイル時間 | 3,108 ms |
コンパイル使用メモリ | 74,436 KB |
実行使用メモリ | 45,480 KB |
最終ジャッジ日時 | 2024-12-23 05:03:52 |
合計ジャッジ時間 | 9,812 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int kk = sc.nextInt(); double[] arr = new double[kk + 1]; arr[0] = 1; double ans = 0; for (int i = 1; i < 100000; i++) { double[] next = new double[kk + 1]; for (int j = 0; j < kk; j++) { for (int k = 1; k <= 6; k++) { if (j + k > kk) { next[0] += arr[j] / 6; } else { next[j + k] += arr[j] / 6; } } } ans += next[kk] * i; arr = next; } System.out.println(ans); } }