結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー 0w10w1
提出日時 2017-04-10 18:56:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 77,992 KB
最終ジャッジ日時 2023-09-25 06:50:32
合計ジャッジ時間 4,225 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,472 KB
testcase_01 AC 68 ms
71,216 KB
testcase_02 AC 69 ms
71,204 KB
testcase_03 AC 69 ms
71,352 KB
testcase_04 AC 123 ms
77,136 KB
testcase_05 AC 69 ms
71,212 KB
testcase_06 AC 144 ms
77,520 KB
testcase_07 AC 141 ms
77,992 KB
testcase_08 AC 125 ms
77,384 KB
testcase_09 AC 127 ms
77,032 KB
testcase_10 AC 70 ms
71,412 KB
testcase_11 AC 90 ms
77,200 KB
testcase_12 AC 68 ms
71,200 KB
testcase_13 AC 93 ms
76,116 KB
testcase_14 AC 70 ms
71,268 KB
testcase_15 AC 80 ms
76,560 KB
testcase_16 AC 71 ms
71,404 KB
testcase_17 AC 74 ms
76,012 KB
testcase_18 AC 134 ms
77,444 KB
testcase_19 AC 115 ms
77,384 KB
testcase_20 AC 115 ms
77,268 KB
testcase_21 AC 129 ms
77,472 KB
testcase_22 AC 124 ms
77,144 KB
testcase_23 AC 135 ms
77,432 KB
testcase_24 AC 135 ms
77,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = int( 1e9 ) + 7

fact = [ 1 ]
inv_fact = [ 1 ]
for i in range( 1, 100, 1 ):
  fact.append( fact[ i - 1 ] * i % MOD )
  inv_fact.append( pow( fact[ i ], MOD - 2, MOD ) )

Gx, Gy, K = map( int, input().split() )
X = []
Y = []
N = []
for i in range( K ):
  x, y, n = map( int, input().split() )
  X.append( x )
  Y.append( y )
  N.append( n )

ans = 0
def dfs( t, x, y, vis = None ):
  if vis == None:
    vis = []
  if t == K:
    if x == Gx and y == Gy:
      f = fact[ sum( vis ) ]
      for i in range( len( vis ) ):
        f = f * inv_fact[ vis[ i ] ] % MOD
      global ans
      ans = ( ans + f ) % MOD
    return
  for i in range( N[ t ] + 1 ):
    vis.append( i )
    dfs( t + 1, x + X[ t ] * i, y + Y[ t ] * i, vis )
    vis.pop()

dfs( 0, 0, 0 )
print( ans )
0