結果
| 問題 |
No.2683 Two Sheets
|
| コンテスト | |
| ユーザー |
arad
|
| 提出日時 | 2023-12-13 17:13:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 416 ms / 2,000 ms |
| コード長 | 2,170 bytes |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 77,356 KB |
| 最終ジャッジ日時 | 2024-09-27 05:28:44 |
| 合計ジャッジ時間 | 5,439 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#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)
arad