結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー titiatitia
提出日時 2023-02-08 01:54:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 257,752 KB
最終ジャッジ日時 2023-09-19 06:10:03
合計ジャッジ時間 32,182 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
257,080 KB
testcase_01 AC 72 ms
71,280 KB
testcase_02 AC 276 ms
256,912 KB
testcase_03 AC 271 ms
257,044 KB
testcase_04 AC 271 ms
257,004 KB
testcase_05 AC 72 ms
71,316 KB
testcase_06 AC 76 ms
71,128 KB
testcase_07 AC 72 ms
71,332 KB
testcase_08 AC 72 ms
71,288 KB
testcase_09 AC 278 ms
255,224 KB
testcase_10 AC 276 ms
256,100 KB
testcase_11 AC 281 ms
257,532 KB
testcase_12 AC 281 ms
255,880 KB
testcase_13 AC 301 ms
257,192 KB
testcase_14 AC 282 ms
257,704 KB
testcase_15 AC 282 ms
254,832 KB
testcase_16 AC 287 ms
256,260 KB
testcase_17 AC 287 ms
256,436 KB
testcase_18 AC 308 ms
254,132 KB
testcase_19 AC 282 ms
257,064 KB
testcase_20 AC 278 ms
256,956 KB
testcase_21 AC 281 ms
256,900 KB
testcase_22 AC 278 ms
257,352 KB
testcase_23 AC 276 ms
256,940 KB
testcase_24 AC 277 ms
256,956 KB
testcase_25 AC 279 ms
257,056 KB
testcase_26 AC 279 ms
257,072 KB
testcase_27 AC 281 ms
256,864 KB
testcase_28 AC 278 ms
257,116 KB
testcase_29 AC 276 ms
256,916 KB
testcase_30 AC 277 ms
256,884 KB
testcase_31 AC 277 ms
256,876 KB
testcase_32 AC 277 ms
256,956 KB
testcase_33 AC 279 ms
256,940 KB
testcase_34 AC 281 ms
257,044 KB
testcase_35 AC 277 ms
257,048 KB
testcase_36 AC 280 ms
256,928 KB
testcase_37 AC 279 ms
256,848 KB
testcase_38 AC 277 ms
256,944 KB
testcase_39 AC 282 ms
257,160 KB
testcase_40 AC 276 ms
256,812 KB
testcase_41 AC 282 ms
256,888 KB
testcase_42 AC 274 ms
257,004 KB
testcase_43 AC 276 ms
257,104 KB
testcase_44 AC 275 ms
256,960 KB
testcase_45 AC 276 ms
256,856 KB
testcase_46 AC 276 ms
256,876 KB
testcase_47 AC 275 ms
257,160 KB
testcase_48 AC 275 ms
257,456 KB
testcase_49 AC 340 ms
251,340 KB
testcase_50 AC 282 ms
254,772 KB
testcase_51 AC 281 ms
255,116 KB
testcase_52 AC 285 ms
255,616 KB
testcase_53 AC 283 ms
256,232 KB
testcase_54 AC 285 ms
256,724 KB
testcase_55 AC 275 ms
257,752 KB
testcase_56 AC 280 ms
255,604 KB
testcase_57 AC 292 ms
256,816 KB
testcase_58 AC 314 ms
256,716 KB
testcase_59 AC 300 ms
250,464 KB
testcase_60 AC 288 ms
256,592 KB
testcase_61 AC 315 ms
254,448 KB
testcase_62 AC 283 ms
256,628 KB
testcase_63 AC 298 ms
256,964 KB
testcase_64 AC 282 ms
256,480 KB
testcase_65 AC 283 ms
255,964 KB
testcase_66 AC 286 ms
256,624 KB
testcase_67 AC 291 ms
256,716 KB
testcase_68 AC 284 ms
255,492 KB
testcase_69 AC 277 ms
256,864 KB
testcase_70 AC 278 ms
256,864 KB
testcase_71 AC 280 ms
257,060 KB
testcase_72 AC 278 ms
256,824 KB
testcase_73 AC 282 ms
256,900 KB
testcase_74 AC 279 ms
256,968 KB
testcase_75 AC 278 ms
256,856 KB
testcase_76 AC 280 ms
257,076 KB
testcase_77 AC 279 ms
256,884 KB
testcase_78 AC 276 ms
257,084 KB
testcase_79 AC 278 ms
257,048 KB
testcase_80 AC 275 ms
256,832 KB
testcase_81 AC 276 ms
257,084 KB
testcase_82 AC 279 ms
256,988 KB
testcase_83 AC 280 ms
256,856 KB
testcase_84 AC 278 ms
257,380 KB
testcase_85 AC 277 ms
256,876 KB
testcase_86 AC 277 ms
256,864 KB
testcase_87 AC 281 ms
256,940 KB
testcase_88 AC 277 ms
256,980 KB
testcase_89 AC 293 ms
256,908 KB
testcase_90 AC 305 ms
257,340 KB
testcase_91 AC 326 ms
250,876 KB
testcase_92 AC 284 ms
256,724 KB
testcase_93 AC 305 ms
250,612 KB
testcase_94 AC 278 ms
257,460 KB
testcase_95 AC 305 ms
250,880 KB
testcase_96 AC 297 ms
257,720 KB
testcase_97 AC 296 ms
257,148 KB
testcase_98 AC 282 ms
255,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M=int(input())
H=list(map(int,input().split()))

if H==[0]:
    print(1)
    exit()

mod=10**9+7

FACT=[1]
for i in range(1,2*10**6+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

x=sum(H)+len(H)-1
rest=M-x

if rest<0:
    print("NA")
else:
    print(Combi(rest+len(H),rest))
0