結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-21 23:43:11
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,627 bytes
コンパイル時間 7,831 ms
コンパイル使用メモリ 156,976 KB
実行使用メモリ 184,248 KB
最終ジャッジ日時 2024-03-21 23:43:24
合計ジャッジ時間 11,237 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
32,548 KB
testcase_01 AC 138 ms
40,740 KB
testcase_02 AC 81 ms
33,060 KB
testcase_03 AC 107 ms
36,644 KB
testcase_04 AC 111 ms
37,412 KB
testcase_05 AC 86 ms
33,956 KB
testcase_06 AC 107 ms
35,492 KB
testcase_07 AC 106 ms
36,004 KB
testcase_08 AC 108 ms
36,516 KB
testcase_09 AC 120 ms
38,308 KB
testcase_10 AC 100 ms
35,364 KB
testcase_11 AC 91 ms
34,596 KB
testcase_12 AC 94 ms
34,724 KB
testcase_13 AC 104 ms
36,132 KB
testcase_14 AC 112 ms
37,284 KB
testcase_15 AC 138 ms
40,228 KB
testcase_16 AC 108 ms
36,644 KB
testcase_17 AC 81 ms
32,932 KB
testcase_18 AC 97 ms
35,236 KB
testcase_19 AC 102 ms
35,620 KB
testcase_20 AC 84 ms
33,700 KB
testcase_21 AC 83 ms
33,188 KB
testcase_22 AC 124 ms
39,204 KB
testcase_23 AC 90 ms
34,212 KB
testcase_24 AC 134 ms
40,740 KB
testcase_25 AC 115 ms
37,924 KB
testcase_26 AC 104 ms
36,260 KB
testcase_27 AC 84 ms
33,700 KB
testcase_28 AC 105 ms
184,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (128 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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (p1, p2, q1, q2, t) = (c[0], c[1], c[2], c[3], c[4]);
        var mod = 998_244_353;
        var p2rev = Exp(p2, mod - 2, mod);
        var q2rev = Exp(q2, mod - 2, mod);
        var prob = new long[t + 1];
        prob[0] = 1;
        prob[1] = q1 * q2rev % mod;
        for (var i = 2; i <= t; ++i)
        {
            prob[i] = prob[i - 1] * prob[1] % mod;
        }
        var dp = new long[t + 1];
        dp[0] = 1;
        for (var i = 0; i < t; ++i)
        {
            var ndp = new long[t + 1];
            for (var j = 0; j < t; ++j)
            {
                ndp[j + 1] = dp[j] * prob[j + 1] % mod;
                ndp[0] = (ndp[0] + dp[j] * p1 % mod * p2rev % mod) % mod;
            }
            dp = ndp;
        }
        var ans = 0L;
        for (var i = 0; i < dp.Length; ++i) ans = (ans + dp[i]) % mod;
        WriteLine(ans);
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0