結果
問題 | 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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,352 KB |
testcase_01 | AC | 35 ms
51,968 KB |
testcase_02 | AC | 89 ms
76,348 KB |
testcase_03 | AC | 372 ms
76,544 KB |
testcase_04 | AC | 163 ms
76,976 KB |
testcase_05 | AC | 338 ms
76,584 KB |
testcase_06 | AC | 316 ms
76,828 KB |
testcase_07 | AC | 275 ms
77,320 KB |
testcase_08 | AC | 403 ms
76,672 KB |
testcase_09 | AC | 265 ms
76,468 KB |
testcase_10 | AC | 399 ms
77,356 KB |
testcase_11 | AC | 365 ms
76,672 KB |
testcase_12 | AC | 327 ms
77,056 KB |
testcase_13 | AC | 416 ms
75,972 KB |
testcase_14 | AC | 400 ms
75,904 KB |
testcase_15 | AC | 338 ms
76,972 KB |
ソースコード
#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)