結果

問題 No.66 輝け☆全国たこやき杯
ユーザー tentententen
提出日時 2020-12-23 08:23:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 3,452 ms
コンパイル使用メモリ 76,908 KB
実行使用メモリ 58,024 KB
最終ジャッジ日時 2023-10-21 15:02:16
合計ジャッジ時間 4,674 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
57,228 KB
testcase_01 AC 99 ms
56,040 KB
testcase_02 AC 108 ms
57,260 KB
testcase_03 AC 100 ms
55,876 KB
testcase_04 AC 111 ms
57,104 KB
testcase_05 AC 118 ms
57,652 KB
testcase_06 AC 123 ms
57,068 KB
testcase_07 AC 127 ms
57,480 KB
testcase_08 AC 163 ms
57,632 KB
testcase_09 AC 195 ms
58,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int length = (1 << m);
        double[] strengths = new double[length];
        for (int i = 0; i < length; i++) {
            strengths[i] = sc.nextInt();
        }
        double[][] dp = new double[m + 1][length];
        Arrays.fill(dp[0], 1);
        for (int i = 1; i <= m; i++) {
            for (int j = 0; j < length; j++) {
                int start = j;
                start >>= i - 1;
                if (start % 2 == 0) {
                    start++;
                } else {
                    start--;
                }
                start <<= i - 1;
                for (int k = start; k < start + (1 << (i - 1)); k++) {
                    dp[i][j] += dp[i - 1][k] * Math.pow(strengths[j], 2) / (Math.pow(strengths[j], 2) + Math.pow(strengths[k], 2));
                }
                dp[i][j] *= dp[i - 1][j];
            }
        }
        System.out.println(dp[m][0]);
    }
}
0