結果
問題 | No.2683 Two Sheets |
ユーザー |
|
提出日時 | 2024-03-20 22:06:30 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,560 bytes |
コンパイル時間 | 8,106 ms |
コンパイル使用メモリ | 165,784 KB |
実行使用メモリ | 185,476 KB |
最終ジャッジ日時 | 2024-09-30 07:57:24 |
合計ジャッジ時間 | 9,366 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 9 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (96 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/
ソースコード
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) { checked { 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 (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 (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; } }