結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー convexineqconvexineq
提出日時 2021-02-02 16:53:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 191,724 KB
最終ジャッジ日時 2023-09-12 11:07:10
合計ジャッジ時間 16,857 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
123,000 KB
testcase_01 AC 125 ms
122,744 KB
testcase_02 AC 124 ms
122,844 KB
testcase_03 AC 125 ms
122,836 KB
testcase_04 AC 126 ms
122,752 KB
testcase_05 AC 126 ms
122,792 KB
testcase_06 AC 126 ms
122,756 KB
testcase_07 AC 125 ms
122,776 KB
testcase_08 AC 127 ms
122,976 KB
testcase_09 AC 133 ms
127,300 KB
testcase_10 AC 130 ms
125,200 KB
testcase_11 AC 136 ms
130,120 KB
testcase_12 AC 130 ms
124,736 KB
testcase_13 AC 157 ms
151,572 KB
testcase_14 AC 134 ms
130,236 KB
testcase_15 AC 126 ms
123,384 KB
testcase_16 AC 130 ms
125,440 KB
testcase_17 AC 134 ms
129,092 KB
testcase_18 AC 192 ms
166,232 KB
testcase_19 AC 125 ms
122,796 KB
testcase_20 AC 124 ms
122,940 KB
testcase_21 AC 123 ms
122,760 KB
testcase_22 AC 124 ms
122,916 KB
testcase_23 AC 124 ms
122,840 KB
testcase_24 AC 125 ms
122,756 KB
testcase_25 AC 125 ms
122,840 KB
testcase_26 AC 125 ms
122,948 KB
testcase_27 AC 124 ms
122,900 KB
testcase_28 AC 123 ms
122,832 KB
testcase_29 AC 125 ms
122,756 KB
testcase_30 AC 123 ms
122,892 KB
testcase_31 AC 125 ms
122,704 KB
testcase_32 AC 126 ms
122,540 KB
testcase_33 AC 128 ms
122,764 KB
testcase_34 AC 125 ms
122,800 KB
testcase_35 AC 124 ms
122,808 KB
testcase_36 AC 123 ms
122,920 KB
testcase_37 AC 125 ms
122,804 KB
testcase_38 AC 125 ms
122,876 KB
testcase_39 AC 125 ms
122,636 KB
testcase_40 AC 126 ms
122,756 KB
testcase_41 AC 124 ms
122,800 KB
testcase_42 AC 126 ms
122,904 KB
testcase_43 AC 124 ms
122,620 KB
testcase_44 AC 127 ms
122,932 KB
testcase_45 AC 125 ms
122,544 KB
testcase_46 AC 125 ms
123,012 KB
testcase_47 AC 126 ms
122,756 KB
testcase_48 AC 125 ms
122,808 KB
testcase_49 AC 192 ms
167,544 KB
testcase_50 AC 127 ms
123,420 KB
testcase_51 AC 129 ms
123,328 KB
testcase_52 AC 136 ms
130,400 KB
testcase_53 AC 129 ms
125,368 KB
testcase_54 AC 137 ms
131,660 KB
testcase_55 AC 127 ms
122,952 KB
testcase_56 AC 132 ms
125,168 KB
testcase_57 AC 154 ms
145,464 KB
testcase_58 AC 187 ms
160,796 KB
testcase_59 AC 170 ms
159,028 KB
testcase_60 AC 140 ms
136,104 KB
testcase_61 AC 212 ms
191,724 KB
testcase_62 AC 144 ms
138,080 KB
testcase_63 AC 188 ms
161,796 KB
testcase_64 AC 138 ms
131,660 KB
testcase_65 AC 134 ms
128,256 KB
testcase_66 AC 142 ms
136,020 KB
testcase_67 AC 139 ms
134,344 KB
testcase_68 AC 139 ms
133,008 KB
testcase_69 AC 127 ms
122,880 KB
testcase_70 AC 124 ms
122,796 KB
testcase_71 AC 125 ms
122,776 KB
testcase_72 AC 126 ms
122,792 KB
testcase_73 AC 123 ms
122,588 KB
testcase_74 AC 126 ms
122,760 KB
testcase_75 AC 127 ms
122,808 KB
testcase_76 AC 125 ms
122,948 KB
testcase_77 AC 124 ms
122,832 KB
testcase_78 AC 125 ms
122,876 KB
testcase_79 AC 127 ms
122,540 KB
testcase_80 AC 125 ms
122,956 KB
testcase_81 AC 124 ms
122,548 KB
testcase_82 AC 126 ms
122,592 KB
testcase_83 AC 125 ms
122,780 KB
testcase_84 AC 123 ms
122,792 KB
testcase_85 AC 124 ms
122,724 KB
testcase_86 AC 126 ms
122,648 KB
testcase_87 AC 125 ms
122,804 KB
testcase_88 AC 124 ms
122,784 KB
testcase_89 AC 148 ms
140,076 KB
testcase_90 AC 159 ms
152,260 KB
testcase_91 AC 193 ms
166,556 KB
testcase_92 AC 135 ms
129,172 KB
testcase_93 AC 172 ms
160,420 KB
testcase_94 AC 128 ms
123,224 KB
testcase_95 AC 176 ms
160,872 KB
testcase_96 AC 155 ms
148,632 KB
testcase_97 AC 154 ms
148,280 KB
testcase_98 AC 138 ms
132,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

SIZE=2*10**6+1; MOD=10**9+7 #998244353 #ここを変更する

inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

m = int(input())
*a, = map(int,input().split())
if a == [0]: print(1);exit()
x = m-sum(a)-len(a)+1
v = choose(x+len(a),x)
print(v if v else "NA")
0