結果

問題 No.66 輝け☆全国たこやき杯
ユーザー nanophoto12nanophoto12
提出日時 2014-11-15 01:40:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 1,730 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 102,696 KB
実行使用メモリ 25,284 KB
最終ジャッジ日時 2023-08-30 03:40:58
合計ジャッジ時間 3,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,188 KB
testcase_01 AC 61 ms
22,784 KB
testcase_02 AC 62 ms
23,192 KB
testcase_03 AC 62 ms
25,192 KB
testcase_04 AC 62 ms
25,284 KB
testcase_05 AC 62 ms
23,088 KB
testcase_06 AC 62 ms
25,140 KB
testcase_07 AC 63 ms
23,304 KB
testcase_08 AC 65 ms
23,172 KB
testcase_09 AC 69 ms
23,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    public static void Main(string[] args)
    {
        var m = int.Parse(Console.ReadLine());
        int count = (int)Math.Round(Math.Pow(2, m));
        double[] strength = new double[count];
        for (int i = 0; i < strength.Length; i++)
        {
            var s = int.Parse(Console.ReadLine());
            strength[i] = s * s;            
        }
        double[,] percentages = new double[m+1,count];
        {
            for (int k = 0; k < count; k++)
            {
                percentages[0, k] = 1;
            }
        }
        for (int i = 1; i <= m; i++)
        {
            for (int k = 0; k < count; k++)
            {
                int block = (int)Math.Round(Math.Pow(2, i));
                int start = block* (k/block);
                int end = start + block;
                if (k < (start + end)/2)
                {
                    start += block/2;
                }
                else
                {
                    end -= block/2;
                }
                double pSum = 0;
                for (int j = start; j < end; j++)
                {
                    if (j == k)
                    {
                        continue;
                    }
                    pSum += percentages[i - 1, j] * strength[k]/(strength[k] + strength[j]);
                }
                percentages[i, k] = percentages[i - 1, k]*pSum;
            }
            //for (int t = 0; t < count; t++)
            //{
            //    Console.Write(percentages[i, t] + ",");
            //}
            //Console.WriteLine();
        }
        Console.WriteLine(percentages[m,0]);

    }
}
0