結果
| 問題 |
No.498 ワープクリスタル (給料日編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-14 09:24:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,319 ms / 2,000 ms |
| コード長 | 757 bytes |
| コンパイル時間 | 380 ms |
| コンパイル使用メモリ | 82,272 KB |
| 実行使用メモリ | 448,792 KB |
| 最終ジャッジ日時 | 2024-07-14 09:24:35 |
| 合計ジャッジ時間 | 16,304 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
from collections import defaultdict
MOD = 10**9 + 7
MAX = 76
fac = [1] * MAX
for i in range(1, MAX):
fac[i] = fac[i - 1] * i % MOD
Gx, Gy, K = map(int, input().split())
cand = defaultdict(list)
cand[(0, 0)] = [[]]
for _ in range(K):
nx, ny, n = map(int, input().split())
new_cand = defaultdict(list)
for (x, y), lst in cand.items():
for crystal in lst:
new_cand[(x, y)].append(crystal + [0])
for i in range(1, n + 1):
new_cand[(x + i * nx, y + i * ny)].append(crystal + [i])
cand = new_cand
res = cand[(Gx, Gy)]
ans = 0
for crystal in res:
tmp = fac[sum(crystal)]
for x in crystal:
tmp *= pow(fac[x], -1, MOD)
tmp %= MOD
ans += tmp
ans %= MOD
print(ans)