結果

問題 No.567 コンプリート
ユーザー htensaihtensai
提出日時 2019-11-14 21:13:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 861 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 133,308 KB
最終ジャッジ日時 2023-10-22 00:10:11
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,412 KB
testcase_01 AC 139 ms
57,488 KB
testcase_02 AC 136 ms
57,596 KB
testcase_03 AC 136 ms
57,216 KB
testcase_04 AC 132 ms
57,424 KB
testcase_05 AC 133 ms
57,372 KB
testcase_06 AC 133 ms
57,384 KB
testcase_07 AC 137 ms
57,572 KB
testcase_08 AC 135 ms
57,420 KB
testcase_09 AC 135 ms
57,596 KB
testcase_10 AC 134 ms
57,596 KB
testcase_11 AC 135 ms
57,368 KB
testcase_12 AC 135 ms
57,476 KB
testcase_13 AC 139 ms
57,416 KB
testcase_14 AC 135 ms
57,536 KB
testcase_15 AC 861 ms
133,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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