結果

問題 No.66 輝け☆全国たこやき杯
ユーザー GrenacheGrenache
提出日時 2016-05-18 19:41:43
言語 Java19
(openjdk 21)
結果
AC  
実行時間 248 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 3,417 ms
コンパイル使用メモリ 78,508 KB
実行使用メモリ 57,092 KB
最終ジャッジ日時 2023-07-28 14:27:03
合計ジャッジ時間 5,754 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,640 KB
testcase_01 AC 126 ms
56,004 KB
testcase_02 AC 127 ms
55,940 KB
testcase_03 AC 128 ms
55,928 KB
testcase_04 AC 131 ms
55,724 KB
testcase_05 AC 136 ms
56,084 KB
testcase_06 AC 153 ms
55,516 KB
testcase_07 AC 166 ms
55,968 KB
testcase_08 AC 215 ms
56,960 KB
testcase_09 AC 248 ms
57,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder66 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int m = sc.nextInt();
        int n = 0x1 << m;
        int[] s = new int[n];

        for (int i = 0; i < n; i++) {
        	s[i] = sc.nextInt();
        }

        double[][] p = new double[m][n];

        for (int i = 0; i < m; i++) {
        	for (int j = 0; j < n; j++) {
        		for (int k = 0; k < n; k++) {
        			int mask = ~((0x1 << i + 1) - 1);
        			int bit = 0x1 << i;
        			if ((j & bit) == (k & bit)) {
        				continue;
        			}
        			if ((j & mask) != (k & mask)) {
        				continue;
        			}

            		if (i > 0) {
            			p[i][j] += p[i - 1][j] * p[i - 1][k] * s[j] * s[j] / (s[j] * s[j] + s[k] * s[k]);
        			} else {
        				p[i][j] += (double)s[j] * s[j] / (s[j] * s[j] + s[k] * s[k]);
        			}
        		}

        	}
        }

        System.out.printf("%.7f\n", p[m - 1][0]);

        sc.close();
    }
}
0