結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー rpy3cpprpy3cpp
提出日時 2017-03-25 20:54:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 874 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 8,520 KB
最終ジャッジ日時 2023-09-20 10:49:08
合計ジャッジ時間 26,664 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,372 KB
testcase_01 AC 17 ms
8,484 KB
testcase_02 AC 16 ms
8,328 KB
testcase_03 AC 16 ms
8,304 KB
testcase_04 AC 1,930 ms
8,340 KB
testcase_05 AC 16 ms
8,492 KB
testcase_06 TLE -
testcase_07 AC 1,935 ms
8,520 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 16 ms
8,376 KB
testcase_11 AC 280 ms
8,308 KB
testcase_12 AC 17 ms
8,332 KB
testcase_13 AC 82 ms
8,376 KB
testcase_14 AC 17 ms
8,392 KB
testcase_15 AC 20 ms
8,464 KB
testcase_16 AC 17 ms
8,312 KB
testcase_17 AC 21 ms
8,332 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0