結果

問題 No.65 回数の期待値の練習
ユーザー GrenacheGrenache
提出日時 2015-07-28 17:11:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 519 bytes
コンパイル時間 4,556 ms
コンパイル使用メモリ 72,732 KB
実行使用メモリ 56,252 KB
最終ジャッジ日時 2023-09-24 12:20:12
合計ジャッジ時間 7,908 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,252 KB
testcase_01 AC 128 ms
55,560 KB
testcase_02 AC 128 ms
56,044 KB
testcase_03 AC 128 ms
56,032 KB
testcase_04 AC 127 ms
56,012 KB
testcase_05 AC 128 ms
56,056 KB
testcase_06 AC 126 ms
55,844 KB
testcase_07 AC 127 ms
55,952 KB
testcase_08 AC 127 ms
55,804 KB
testcase_09 AC 127 ms
55,680 KB
testcase_10 AC 127 ms
55,712 KB
testcase_11 AC 129 ms
55,836 KB
testcase_12 AC 128 ms
56,012 KB
testcase_13 AC 127 ms
55,764 KB
testcase_14 AC 128 ms
55,548 KB
testcase_15 AC 128 ms
55,908 KB
testcase_16 AC 127 ms
55,860 KB
testcase_17 AC 127 ms
56,008 KB
testcase_18 AC 128 ms
55,824 KB
testcase_19 AC 128 ms
56,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder65 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();

        double[] e = new double[k + 1];
        e[k] = 0.0;
        for (int i = k - 1; i >= 0; i--) {
        	e[i] = 1;
        	for (int j = 0; j < 6; j++) {
        		if (i + j + 1 <= k) {
        			e[i] += e[i + j + 1] / 6;
        		}
        	}
        }

        System.out.printf("%.3f\n", e[0]);

        sc.close();
    }
}
0