結果

問題 No.2683 Two Sheets
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-20 22:00:10
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 7,358 ms
コンパイル使用メモリ 157,076 KB
実行使用メモリ 180,508 KB
最終ジャッジ日時 2024-03-20 22:00:21
合計ジャッジ時間 10,099 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
32,548 KB
testcase_01 AC 77 ms
32,548 KB
testcase_02 AC 77 ms
32,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 78 ms
32,548 KB
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (105 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 (h, w, a, b) = (c[0], c[1], c[2], c[3]);

        var mod = 998_244_353;
        var p = 0L;
        var q = 0L;
        for (var i = 1; i <= a; ++i)
        {
            var count = h + i - 2 * a + 1;
            if (i < a) count *= 2;
            p = (p + count % mod * i % mod) % mod;
        }
        for (var j = 1; j <= b; ++j)
        {
            var count = w + j - 2 * b + 1;
            if (j < b) count *= 2;
            q = (q + count % mod * j % mod) % mod;
        }
        var hp = Exp(h - a + 1, mod - 2, mod);
        var wp = Exp(w - b + 1, mod - 2, mod);
        WriteLine((2L * a * b - p * q % mod * hp % mod * hp % mod * wp % mod * wp % mod + mod) % mod);
    }
    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