結果
| 問題 |
No.498 ワープクリスタル (給料日編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-16 16:31:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 115 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2024-07-02 20:00:56 |
| 合計ジャッジ時間 | 3,768 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | TLE * 1 -- * 20 |
ソースコード
from collections import deque
def inv(x):
return pow(x, MOD-2, MOD)
def dfs(d, q):
if d==K:
x, y = 0, 0
res = fact[sum(q)]
for (xi, yi, _), qi in zip(xyN, q):
x += xi*qi
y += yi*qi
res *= inv(fact[qi])
if x==Gx and y==Gy:
return res
else:
return 0
res = 0
for i in range(xyN[d][2]+1):
q.append(i)
res += dfs(d+1, q)
res %= MOD
q.pop()
return res
Gx, Gy, K = map(int, input().split())
xyN = [tuple(map(int, input().split())) for _ in range(K)]
MOD = 10**9+7
fact = [1]
for i in range(1, 100):
fact.append(fact[-1]*i%MOD)
print(dfs(0, deque([])))