結果

問題 No.66 輝け☆全国たこやき杯
ユーザー GrenacheGrenache
提出日時 2016-05-18 19:41:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 3,586 ms
コンパイル使用メモリ 78,228 KB
実行使用メモリ 55,060 KB
最終ジャッジ日時 2024-04-15 22:56:27
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
54,152 KB
testcase_01 AC 134 ms
54,016 KB
testcase_02 AC 141 ms
54,156 KB
testcase_03 AC 139 ms
54,272 KB
testcase_04 AC 141 ms
54,068 KB
testcase_05 AC 147 ms
54,436 KB
testcase_06 AC 165 ms
54,440 KB
testcase_07 AC 178 ms
54,276 KB
testcase_08 AC 225 ms
55,060 KB
testcase_09 AC 268 ms
54,804 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