結果
問題 | No.2527 H and W |
ユーザー |
👑 |
提出日時 | 2024-08-15 21:20:19 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 326 ms / 2,000 ms |
コード長 | 1,303 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 7,068 KB |
実行使用メモリ | 52,088 KB |
最終ジャッジ日時 | 2024-08-15 21:20:29 |
合計ジャッジ時間 | 9,688 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
local mod = 998244353local mfl = math.floorlocal function bmul(x, y)local x0, y0 = x % 31596, y % 31596local x1, y1 = mfl(x / 31596), mfl(y / 31596)return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % modendlocal function badd(x, y)return (x + y) % modendlocal function bsub(x, y)return x < y and x - y + mod or x - yendlocal function modpow(src, pow)local res = 1while 0 < pow doif pow % 2 == 1 thenres = bmul(res, src)pow = pow - 1endsrc = bmul(src, src)pow = mfl(pow / 2)endreturn resendlocal function modinv(src)return modpow(src, mod - 2)endlocal fact = {1}local invs = {1}local invfact = {1}for i = 2, 2000 * 1000 + 100 dofact[i] = bmul(fact[i - 1], i)invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])invfact[i] = bmul(invfact[i - 1], invs[i])endlocal function getComb(n, k)if k == 0 or k == n then return 1 endreturn bmul(fact[n], bmul(invfact[k], invfact[n - k]))endlocal h, w, k = io.read("*n", "*n", "*n")if k == h * w thenprint(1)os.exit()endlocal ans = 0for i = 1, h doif k % i == 0 thenlocal j = mfl(k / i)if j <= w thenlocal v1 = getComb(h, i)local v2 = getComb(w, j)ans = badd(ans, bmul(v1, v2))endendendprint(ans)