結果
問題 | No.2683 Two Sheets |
ユーザー | arad |
提出日時 | 2023-12-13 17:13:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 451 ms / 2,000 ms |
コード長 | 2,170 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 77,020 KB |
最終ジャッジ日時 | 2023-12-13 17:13:33 |
合計ジャッジ時間 | 5,955 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,460 KB |
testcase_01 | AC | 38 ms
53,460 KB |
testcase_02 | AC | 96 ms
76,128 KB |
testcase_03 | AC | 385 ms
76,612 KB |
testcase_04 | AC | 195 ms
77,020 KB |
testcase_05 | AC | 366 ms
76,356 KB |
testcase_06 | AC | 326 ms
76,516 KB |
testcase_07 | AC | 287 ms
76,516 KB |
testcase_08 | AC | 451 ms
76,612 KB |
testcase_09 | AC | 281 ms
76,228 KB |
testcase_10 | AC | 418 ms
76,740 KB |
testcase_11 | AC | 412 ms
76,500 KB |
testcase_12 | AC | 345 ms
76,612 KB |
testcase_13 | AC | 431 ms
75,968 KB |
testcase_14 | AC | 442 ms
75,972 KB |
testcase_15 | AC | 357 ms
76,484 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)