結果

問題 No.2683 Two Sheets
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-20 22:27:19
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,625 bytes
コンパイル時間 13,294 ms
コンパイル使用メモリ 167,128 KB
実行使用メモリ 184,988 KB
最終ジャッジ日時 2024-04-17 11:16:16
合計ジャッジ時間 15,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
30,208 KB
testcase_01 AC 54 ms
30,460 KB
testcase_02 AC 53 ms
29,952 KB
testcase_03 AC 57 ms
30,592 KB
testcase_04 AC 54 ms
30,592 KB
testcase_05 AC 58 ms
30,464 KB
testcase_06 AC 57 ms
30,464 KB
testcase_07 AC 57 ms
30,464 KB
testcase_08 AC 58 ms
30,328 KB
testcase_09 AC 59 ms
30,592 KB
testcase_10 AC 60 ms
30,592 KB
testcase_11 AC 59 ms
30,464 KB
testcase_12 AC 58 ms
30,464 KB
testcase_13 AC 54 ms
30,464 KB
testcase_14 AC 53 ms
30,336 KB
testcase_15 AC 59 ms
184,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (139 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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]);
        WriteLine(Sheets(h, w, a, b));
    }
    static long Sheets(int h, int w, int a, int b)
    {
        var mod = 998_244_353;
        var p = 0L;
        var q = 0L;
        for (var i = 1; i <= a; ++i)
        {
            var count = h + i - 2L * a + 1;
            if (count < 0) continue;
            if (i < a) count *= 2;
            p = (p + count % mod * i % mod) % mod;
        }
        for (var j = 1; j <= b; ++j)
        {
            var count = w + j - 2L * b + 1;
            if (count < 0) continue;
            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);
        return (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