結果

問題 No.65 回数の期待値の練習
ユーザー tentententen
提出日時 2020-12-07 14:37:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 57,644 KB
最終ジャッジ日時 2023-10-17 16:30:04
合計ジャッジ時間 5,788 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
57,096 KB
testcase_01 AC 129 ms
57,068 KB
testcase_02 AC 130 ms
57,628 KB
testcase_03 AC 128 ms
57,364 KB
testcase_04 AC 128 ms
57,532 KB
testcase_05 AC 126 ms
57,644 KB
testcase_06 AC 127 ms
57,404 KB
testcase_07 AC 129 ms
57,432 KB
testcase_08 AC 129 ms
57,540 KB
testcase_09 AC 126 ms
57,212 KB
testcase_10 AC 129 ms
57,556 KB
testcase_11 AC 130 ms
57,384 KB
testcase_12 AC 129 ms
57,476 KB
testcase_13 AC 129 ms
57,388 KB
testcase_14 AC 129 ms
57,412 KB
testcase_15 AC 130 ms
57,332 KB
testcase_16 AC 128 ms
57,164 KB
testcase_17 AC 126 ms
57,512 KB
testcase_18 AC 127 ms
57,488 KB
testcase_19 AC 127 ms
57,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] dp = new double[n + 6];
        for (int i = n - 1; i >= 0; i--) {
            dp[i] = 1;
            for (int j = 1; j <= 6; j++) {
                dp[i] += dp[i + j] / 6;
            }
        }
        System.out.println(dp[0]);
    }
}
0