結果

問題 No.2683 Two Sheets
ユーザー aradarad
提出日時 2023-12-13 17:12:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 2,170 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-12-13 17:13:06
合計ジャッジ時間 24,975 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,240 KB
testcase_01 AC 30 ms
10,240 KB
testcase_02 AC 139 ms
10,240 KB
testcase_03 TLE -
testcase_04 AC 447 ms
10,240 KB
testcase_05 AC 1,903 ms
10,240 KB
testcase_06 AC 1,598 ms
10,240 KB
testcase_07 AC 1,328 ms
10,240 KB
testcase_08 TLE -
testcase_09 AC 1,412 ms
10,240 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,722 ms
10,240 KB
testcase_13 AC 1,774 ms
10,240 KB
testcase_14 TLE -
testcase_15 AC 1,848 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#https://qiita.com/wotsushi/items/c936838df992b706084c
MOD = 998244353
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )

h, w, a, b = map(int, input().split())
ans0 = ModInt(0)
for i in range(h):
    l = max(0, i - a + 1)
    r = min(h - a, i)
    ad = ModInt(r - l + 1) / (h - a + 1)
    ad *= ad
    ans0 += ad

ans1 = ModInt(0)
for i in range(w):
    l = max(0, i - b + 1)
    r = min(w - b, i)
    ad = ModInt(r - l + 1) / (w - b + 1)
    ad *= ad
    ans1 += ad

ans = ans0 * ans1
ans = 2 * ModInt(a) * ModInt(b) - ans
print(ans)
0