結果

問題 No.567 コンプリート
ユーザー Grenache
提出日時 2017-09-08 23:25:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 701 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 4,602 ms
コンパイル使用メモリ 75,424 KB
実行使用メモリ 88,284 KB
最終ジャッジ日時 2024-12-14 15:11:17
合計ジャッジ時間 7,243 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder567 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		double[][] dp = new double[6][n];
		dp[0][0] = 1;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 6; j++) {
				dp[j][i] += dp[j][i - 1] * (j + 1) / 6;
				if (j > 0) {
					dp[j][i] += dp[j - 1][i - 1] * (6 - (j)) / 6;
				}
			}

//			pr.println(dp[0][i] + dp[1][i] + dp[2][i] + dp[3][i] + dp[4][i] + dp[5][i]);
		}

		pr.printf("%.8f\n", dp[5][n - 1]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0