結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー nebukuro09
提出日時 2017-03-24 23:19:21
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 76,844 KB
実行使用メモリ 78,756 KB
最終ジャッジ日時 2024-07-06 00:02:38
合計ジャッジ時間 6,014 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

Gx, Gy, K = map(int, raw_input().split())
C = [[] for _ in xrange(K)]
for i in xrange(K):
    x, y, n = map(int, raw_input().split())
    for j in xrange(n+1):
        C[i].append((x*j, y*j, j))

F = [1 for _ in xrange(76)]
for i in xrange(1, 76):
    F[i] = F[i-1] * i

ans = 0
for p in itertools.product(*C):
    x, y = 0, 0
    a = []
    for i in p:
        x += i[0]
        y += i[1]
        a.append(i[2])
    if Gx == x and Gy == y:
        b = 1
        for aa in a:
            b *= F[aa]
        ans += F[sum(a)] / b

print ans % 1000000007
0