結果
| 問題 |
No.498 ワープクリスタル (給料日編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-25 20:54:26 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 874 bytes |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-07-06 06:16:47 |
| 合計ジャッジ時間 | 31,011 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 TLE * 12 |
ソースコード
import itertools
import math
def read_data():
Gx, Gy, K = map(int, input().split())
xs = []
ys = []
Ns = []
for k in range(K):
x, y, N = map(int, input().split())
xs.append(x)
ys.append(y)
Ns.append(N)
return Gx, Gy, K, xs, ys, Ns
def solve(Gx, Gy, K, xs, ys, Ns):
mod = 10**9 + 7
counts = 0
patterns = [range(n + 1) for n in Ns]
for ns in itertools.product(*patterns):
X = sum(n * x for n, x in zip(ns, xs))
Y = sum(n * y for n, y in zip(ns, ys))
if X == Gx and Y == Gy:
counts += count_patterns(ns, mod)
counts %= mod
return counts
def count_patterns(ns, mod):
num = math.factorial(sum(ns))
for n in ns:
num //= math.factorial(n)
return num % mod
Gx, Gy, K, xs, ys, Ns = read_data()
print(solve(Gx, Gy, K, xs, ys, Ns))