結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー |
![]() |
提出日時 | 2020-12-05 16:39:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 143,244 KB |
最終ジャッジ日時 | 2024-09-15 18:01:35 |
合計ジャッジ時間 | 9,344 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 99 |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) M = I() H = LI() K = len(H) mod = 10**9+7 a = M-sum(H)+1 if a < K: print('NA') exit() if H[0] == 0: print(1) exit() fac = [1,1] for i in range(2,a+1): fac.append((fac[-1]*i) % mod) print((fac[a]*pow(fac[K],mod-2,mod)*pow(fac[a-K],mod-2,mod)) % mod)