結果

問題 No.567 コンプリート
ユーザー tentententen
提出日時 2024-03-07 14:32:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 1,444 bytes
コンパイル時間 6,379 ms
コンパイル使用メモリ 78,152 KB
実行使用メモリ 136,892 KB
最終ジャッジ日時 2024-03-07 14:32:50
合計ジャッジ時間 9,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
54,496 KB
testcase_01 AC 53 ms
54,248 KB
testcase_02 AC 54 ms
54,488 KB
testcase_03 AC 54 ms
54,472 KB
testcase_04 AC 58 ms
54,492 KB
testcase_05 AC 54 ms
54,476 KB
testcase_06 AC 53 ms
54,496 KB
testcase_07 AC 54 ms
54,488 KB
testcase_08 AC 54 ms
54,476 KB
testcase_09 AC 55 ms
54,500 KB
testcase_10 AC 54 ms
54,488 KB
testcase_11 AC 54 ms
54,228 KB
testcase_12 AC 54 ms
54,488 KB
testcase_13 AC 55 ms
54,464 KB
testcase_14 AC 54 ms
54,484 KB
testcase_15 AC 801 ms
136,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        double[][] dp = new double[n + 1][7];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= 6; j++) {
                dp[i][j] = dp[i - 1][j - 1] * (6 - j + 1) / 6 + dp[i - 1][j] * j / 6;
            }
        }
        System.out.println(new java.math.BigDecimal(dp[n][6]).toPlainString());
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0