結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー ayaoniayaoni
提出日時 2020-12-05 16:39:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 134,844 KB
最終ジャッジ日時 2023-10-13 22:18:08
合計ジャッジ時間 13,746 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,196 KB
testcase_01 AC 66 ms
71,168 KB
testcase_02 AC 69 ms
71,488 KB
testcase_03 AC 66 ms
71,316 KB
testcase_04 AC 103 ms
123,664 KB
testcase_05 AC 68 ms
71,252 KB
testcase_06 AC 68 ms
71,236 KB
testcase_07 AC 68 ms
71,352 KB
testcase_08 AC 66 ms
71,240 KB
testcase_09 AC 108 ms
127,768 KB
testcase_10 AC 80 ms
83,820 KB
testcase_11 AC 111 ms
130,356 KB
testcase_12 AC 75 ms
78,388 KB
testcase_13 AC 107 ms
111,692 KB
testcase_14 AC 81 ms
86,136 KB
testcase_15 AC 80 ms
83,160 KB
testcase_16 AC 91 ms
98,512 KB
testcase_17 AC 107 ms
114,468 KB
testcase_18 AC 137 ms
122,524 KB
testcase_19 AC 69 ms
71,236 KB
testcase_20 AC 68 ms
71,268 KB
testcase_21 AC 67 ms
71,592 KB
testcase_22 AC 69 ms
71,488 KB
testcase_23 AC 70 ms
71,416 KB
testcase_24 AC 73 ms
71,348 KB
testcase_25 AC 72 ms
71,236 KB
testcase_26 AC 71 ms
71,316 KB
testcase_27 AC 71 ms
71,372 KB
testcase_28 AC 72 ms
71,388 KB
testcase_29 AC 72 ms
71,136 KB
testcase_30 AC 72 ms
71,520 KB
testcase_31 AC 73 ms
71,044 KB
testcase_32 AC 72 ms
71,036 KB
testcase_33 AC 71 ms
71,352 KB
testcase_34 AC 73 ms
71,360 KB
testcase_35 AC 68 ms
71,548 KB
testcase_36 AC 72 ms
71,192 KB
testcase_37 AC 72 ms
71,368 KB
testcase_38 AC 72 ms
71,240 KB
testcase_39 AC 72 ms
71,364 KB
testcase_40 AC 72 ms
71,284 KB
testcase_41 AC 72 ms
71,188 KB
testcase_42 AC 72 ms
71,520 KB
testcase_43 AC 125 ms
71,392 KB
testcase_44 AC 92 ms
71,120 KB
testcase_45 AC 71 ms
71,276 KB
testcase_46 AC 70 ms
71,232 KB
testcase_47 AC 71 ms
71,240 KB
testcase_48 AC 72 ms
71,332 KB
testcase_49 AC 135 ms
112,560 KB
testcase_50 AC 79 ms
76,040 KB
testcase_51 AC 78 ms
76,076 KB
testcase_52 AC 86 ms
81,980 KB
testcase_53 AC 82 ms
77,536 KB
testcase_54 AC 84 ms
82,908 KB
testcase_55 AC 77 ms
75,752 KB
testcase_56 AC 79 ms
77,092 KB
testcase_57 AC 94 ms
94,632 KB
testcase_58 AC 117 ms
116,584 KB
testcase_59 AC 103 ms
103,928 KB
testcase_60 AC 84 ms
87,068 KB
testcase_61 AC 145 ms
129,372 KB
testcase_62 AC 85 ms
88,520 KB
testcase_63 AC 115 ms
116,696 KB
testcase_64 AC 82 ms
82,928 KB
testcase_65 AC 80 ms
79,892 KB
testcase_66 AC 84 ms
86,668 KB
testcase_67 AC 80 ms
85,288 KB
testcase_68 AC 81 ms
84,204 KB
testcase_69 AC 91 ms
101,636 KB
testcase_70 AC 81 ms
86,732 KB
testcase_71 AC 86 ms
93,792 KB
testcase_72 AC 80 ms
82,208 KB
testcase_73 AC 82 ms
89,812 KB
testcase_74 AC 88 ms
96,124 KB
testcase_75 AC 83 ms
91,908 KB
testcase_76 AC 76 ms
81,504 KB
testcase_77 AC 96 ms
109,280 KB
testcase_78 AC 73 ms
76,368 KB
testcase_79 AC 68 ms
71,388 KB
testcase_80 AC 69 ms
71,588 KB
testcase_81 AC 68 ms
71,360 KB
testcase_82 AC 69 ms
71,040 KB
testcase_83 AC 69 ms
71,520 KB
testcase_84 AC 70 ms
71,440 KB
testcase_85 AC 70 ms
71,348 KB
testcase_86 AC 71 ms
71,392 KB
testcase_87 AC 68 ms
71,604 KB
testcase_88 AC 69 ms
71,248 KB
testcase_89 AC 97 ms
98,072 KB
testcase_90 AC 112 ms
113,364 KB
testcase_91 AC 150 ms
134,844 KB
testcase_92 AC 86 ms
83,468 KB
testcase_93 AC 118 ms
118,520 KB
testcase_94 AC 74 ms
76,504 KB
testcase_95 AC 119 ms
121,968 KB
testcase_96 AC 106 ms
108,864 KB
testcase_97 AC 105 ms
107,408 KB
testcase_98 AC 87 ms
88,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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