結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー convexineqconvexineq
提出日時 2021-02-02 16:52:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 695 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 191,336 KB
最終ジャッジ日時 2023-09-12 11:06:52
合計ジャッジ時間 17,885 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
122,768 KB
testcase_01 WA -
testcase_02 AC 127 ms
122,832 KB
testcase_03 AC 125 ms
122,840 KB
testcase_04 AC 126 ms
122,608 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 133 ms
127,340 KB
testcase_10 AC 132 ms
125,348 KB
testcase_11 AC 137 ms
130,100 KB
testcase_12 AC 131 ms
124,984 KB
testcase_13 AC 156 ms
151,596 KB
testcase_14 AC 136 ms
130,084 KB
testcase_15 AC 128 ms
123,436 KB
testcase_16 AC 128 ms
125,212 KB
testcase_17 AC 135 ms
129,044 KB
testcase_18 AC 193 ms
166,016 KB
testcase_19 AC 125 ms
122,772 KB
testcase_20 AC 128 ms
122,660 KB
testcase_21 AC 126 ms
122,660 KB
testcase_22 AC 125 ms
122,836 KB
testcase_23 AC 126 ms
122,656 KB
testcase_24 AC 125 ms
122,756 KB
testcase_25 AC 125 ms
122,552 KB
testcase_26 AC 125 ms
122,540 KB
testcase_27 AC 125 ms
122,756 KB
testcase_28 AC 126 ms
122,736 KB
testcase_29 AC 124 ms
122,616 KB
testcase_30 AC 124 ms
122,784 KB
testcase_31 AC 123 ms
122,916 KB
testcase_32 AC 127 ms
122,892 KB
testcase_33 AC 124 ms
122,772 KB
testcase_34 AC 123 ms
122,740 KB
testcase_35 AC 123 ms
122,680 KB
testcase_36 AC 124 ms
122,692 KB
testcase_37 AC 123 ms
122,656 KB
testcase_38 AC 123 ms
122,944 KB
testcase_39 AC 125 ms
122,920 KB
testcase_40 AC 125 ms
122,764 KB
testcase_41 AC 126 ms
122,768 KB
testcase_42 AC 124 ms
122,900 KB
testcase_43 AC 125 ms
122,760 KB
testcase_44 AC 128 ms
122,540 KB
testcase_45 AC 126 ms
122,608 KB
testcase_46 AC 126 ms
122,808 KB
testcase_47 AC 126 ms
122,808 KB
testcase_48 AC 126 ms
122,640 KB
testcase_49 AC 197 ms
167,428 KB
testcase_50 AC 129 ms
123,216 KB
testcase_51 AC 131 ms
123,364 KB
testcase_52 AC 137 ms
130,532 KB
testcase_53 AC 133 ms
125,644 KB
testcase_54 AC 139 ms
131,748 KB
testcase_55 AC 128 ms
123,248 KB
testcase_56 AC 130 ms
125,080 KB
testcase_57 AC 149 ms
145,532 KB
testcase_58 AC 186 ms
160,960 KB
testcase_59 AC 171 ms
159,116 KB
testcase_60 AC 142 ms
136,432 KB
testcase_61 AC 211 ms
191,336 KB
testcase_62 AC 143 ms
138,116 KB
testcase_63 AC 183 ms
161,616 KB
testcase_64 AC 139 ms
131,968 KB
testcase_65 AC 132 ms
128,152 KB
testcase_66 AC 141 ms
136,132 KB
testcase_67 AC 141 ms
134,380 KB
testcase_68 AC 141 ms
133,008 KB
testcase_69 AC 125 ms
122,836 KB
testcase_70 AC 123 ms
122,760 KB
testcase_71 AC 126 ms
122,716 KB
testcase_72 AC 124 ms
122,644 KB
testcase_73 AC 124 ms
122,660 KB
testcase_74 AC 125 ms
122,544 KB
testcase_75 AC 124 ms
122,644 KB
testcase_76 AC 124 ms
122,984 KB
testcase_77 AC 125 ms
122,924 KB
testcase_78 AC 124 ms
122,860 KB
testcase_79 AC 125 ms
122,716 KB
testcase_80 AC 125 ms
122,664 KB
testcase_81 AC 126 ms
122,588 KB
testcase_82 AC 125 ms
122,808 KB
testcase_83 AC 125 ms
122,660 KB
testcase_84 AC 125 ms
122,660 KB
testcase_85 AC 125 ms
122,800 KB
testcase_86 AC 124 ms
122,660 KB
testcase_87 AC 125 ms
122,664 KB
testcase_88 AC 125 ms
122,640 KB
testcase_89 AC 147 ms
140,076 KB
testcase_90 AC 159 ms
152,260 KB
testcase_91 AC 196 ms
166,504 KB
testcase_92 AC 135 ms
128,912 KB
testcase_93 AC 172 ms
160,496 KB
testcase_94 AC 128 ms
122,864 KB
testcase_95 AC 175 ms
160,712 KB
testcase_96 AC 158 ms
148,648 KB
testcase_97 AC 154 ms
148,296 KB
testcase_98 AC 142 ms
132,852 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(m);exit()
x = m-sum(a)-len(a)+1
v = choose(x+len(a),x)
print(v if v else "NA")
0