結果

問題 No.1688 Veterinarian
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-01 23:11:51
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 148 ms / 3,000 ms
コード長 2,177 bytes
コンパイル時間 14,312 ms
コンパイル使用メモリ 158,852 KB
実行使用メモリ 183,980 KB
最終ジャッジ日時 2024-01-01 23:12:09
合計ジャッジ時間 11,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
33,060 KB
testcase_01 AC 129 ms
41,764 KB
testcase_02 AC 98 ms
36,644 KB
testcase_03 AC 86 ms
33,060 KB
testcase_04 AC 87 ms
33,060 KB
testcase_05 AC 88 ms
33,060 KB
testcase_06 AC 125 ms
42,020 KB
testcase_07 AC 87 ms
33,060 KB
testcase_08 AC 148 ms
44,520 KB
testcase_09 AC 145 ms
43,428 KB
testcase_10 AC 120 ms
42,788 KB
testcase_11 AC 106 ms
39,332 KB
testcase_12 AC 88 ms
33,060 KB
testcase_13 AC 110 ms
41,380 KB
testcase_14 AC 93 ms
35,492 KB
testcase_15 AC 128 ms
44,452 KB
testcase_16 AC 94 ms
183,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (106 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var p = NList;
        var (a, b, c, n) = (p[0], p[1], p[2], p[3]);
        var dp = new double[132652];
        dp[Key(a, b, c)] = 1;
        for (var i = 0; i < n; ++i)
        {
            var ndp = new double[132652];
            for (var j = 0; j < dp.Length; ++j)
            {
                if (dp[j] == 0) continue;
                var (x, y, z) = FromKey(j);
                var all = (x + y + z) * (x + y + z - 1) / 2;
                var prob = dp[j];
                if (x > 1)
                {
                    var px = dp[j] * x * (x - 1) / 2 / all;
                    prob -= px;
                    ndp[Key(x - 1, y, z)] += px;
                }
                if (y > 1)
                {
                    var py = dp[j] * y * (y - 1) / 2 / all;
                    prob -= py;
                    ndp[Key(x, y - 1, z)] += py;
                }
                if (z > 1)
                {
                    var pz = dp[j] * z * (z - 1) / 2 / all;
                    prob -= pz;
                    ndp[Key(x, y, z - 1)] += pz;
                }
                ndp[j] += prob;
            }
            dp = ndp;
        }
        var ax = 0.0;
        var ay = 0.0;
        var az = 0.0;
        for (var i = 0; i < dp.Length; ++i)
        {
            var (x, y, z) = FromKey(i);
            ax += (a - x) * dp[i];
            ay += (b - y) * dp[i];
            az += (c - z) * dp[i];
        }
        WriteLine($"{ax} {ay} {az}");
    }
    static int Key(int a, int b, int c)
    {
        return a * 2601 + b * 51 + c;
    }
    static (int a, int b, int c) FromKey(int key)
    {
        return (key / 2601, key / 51 % 51, key % 51);
    }
}
0