結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー pluto77pluto77
提出日時 2016-10-22 10:36:20
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,319 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 7,052 KB
実行使用メモリ 108,212 KB
最終ジャッジ日時 2023-08-15 10:42:14
合計ジャッジ時間 123,752 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,155 ms
101,204 KB
testcase_01 AC 1,148 ms
101,208 KB
testcase_02 AC 1,158 ms
101,208 KB
testcase_03 AC 1,169 ms
101,152 KB
testcase_04 AC 1,156 ms
101,152 KB
testcase_05 AC 1,159 ms
101,328 KB
testcase_06 AC 1,148 ms
101,332 KB
testcase_07 AC 1,165 ms
101,212 KB
testcase_08 AC 1,154 ms
101,312 KB
testcase_09 AC 1,165 ms
102,084 KB
testcase_10 AC 1,167 ms
101,576 KB
testcase_11 AC 1,172 ms
102,056 KB
testcase_12 AC 1,170 ms
101,704 KB
testcase_13 AC 1,219 ms
104,068 KB
testcase_14 AC 1,180 ms
102,232 KB
testcase_15 AC 1,161 ms
101,660 KB
testcase_16 AC 1,167 ms
101,664 KB
testcase_17 AC 1,183 ms
102,008 KB
testcase_18 AC 1,275 ms
106,328 KB
testcase_19 AC 1,159 ms
101,208 KB
testcase_20 AC 1,162 ms
101,216 KB
testcase_21 AC 1,171 ms
101,208 KB
testcase_22 AC 1,161 ms
101,172 KB
testcase_23 AC 1,168 ms
101,252 KB
testcase_24 AC 1,167 ms
101,336 KB
testcase_25 AC 1,160 ms
101,176 KB
testcase_26 AC 1,157 ms
101,304 KB
testcase_27 AC 1,168 ms
101,240 KB
testcase_28 AC 1,161 ms
101,324 KB
testcase_29 AC 1,169 ms
101,240 KB
testcase_30 AC 1,155 ms
101,156 KB
testcase_31 AC 1,182 ms
101,212 KB
testcase_32 AC 1,190 ms
101,352 KB
testcase_33 AC 1,145 ms
101,152 KB
testcase_34 AC 1,167 ms
101,316 KB
testcase_35 AC 1,153 ms
101,244 KB
testcase_36 AC 1,168 ms
101,152 KB
testcase_37 AC 1,167 ms
101,172 KB
testcase_38 AC 1,172 ms
101,332 KB
testcase_39 AC 1,178 ms
101,336 KB
testcase_40 AC 1,153 ms
101,212 KB
testcase_41 AC 1,155 ms
101,212 KB
testcase_42 AC 1,157 ms
101,304 KB
testcase_43 AC 1,169 ms
101,244 KB
testcase_44 AC 1,151 ms
101,332 KB
testcase_45 AC 1,154 ms
101,180 KB
testcase_46 AC 1,160 ms
101,204 KB
testcase_47 AC 1,165 ms
101,156 KB
testcase_48 AC 1,158 ms
101,152 KB
testcase_49 AC 1,310 ms
106,340 KB
testcase_50 AC 1,168 ms
101,936 KB
testcase_51 AC 1,167 ms
101,584 KB
testcase_52 AC 1,173 ms
104,312 KB
testcase_53 AC 1,186 ms
101,880 KB
testcase_54 AC 1,180 ms
105,036 KB
testcase_55 AC 1,160 ms
101,516 KB
testcase_56 AC 1,173 ms
101,568 KB
testcase_57 AC 1,209 ms
103,548 KB
testcase_58 AC 1,260 ms
105,760 KB
testcase_59 AC 1,247 ms
104,580 KB
testcase_60 AC 1,192 ms
102,752 KB
testcase_61 AC 1,319 ms
108,212 KB
testcase_62 AC 1,194 ms
102,996 KB
testcase_63 AC 1,263 ms
105,836 KB
testcase_64 AC 1,216 ms
104,948 KB
testcase_65 AC 1,184 ms
101,960 KB
testcase_66 AC 1,200 ms
102,616 KB
testcase_67 AC 1,201 ms
102,972 KB
testcase_68 AC 1,185 ms
105,236 KB
testcase_69 AC 1,162 ms
101,156 KB
testcase_70 AC 1,168 ms
101,180 KB
testcase_71 AC 1,172 ms
101,320 KB
testcase_72 AC 1,163 ms
101,300 KB
testcase_73 AC 1,155 ms
101,204 KB
testcase_74 AC 1,156 ms
101,328 KB
testcase_75 AC 1,167 ms
101,336 KB
testcase_76 AC 1,162 ms
101,156 KB
testcase_77 AC 1,159 ms
101,248 KB
testcase_78 AC 1,171 ms
101,208 KB
testcase_79 AC 1,158 ms
101,256 KB
testcase_80 AC 1,159 ms
101,240 KB
testcase_81 AC 1,179 ms
101,168 KB
testcase_82 AC 1,176 ms
101,204 KB
testcase_83 AC 1,168 ms
101,208 KB
testcase_84 AC 1,177 ms
101,312 KB
testcase_85 AC 1,168 ms
101,348 KB
testcase_86 AC 1,170 ms
101,320 KB
testcase_87 AC 1,168 ms
101,248 KB
testcase_88 AC 1,171 ms
101,156 KB
testcase_89 AC 1,214 ms
103,012 KB
testcase_90 AC 1,241 ms
104,316 KB
testcase_91 AC 1,292 ms
106,332 KB
testcase_92 AC 1,191 ms
101,976 KB
testcase_93 AC 1,270 ms
104,264 KB
testcase_94 AC 1,193 ms
101,492 KB
testcase_95 AC 1,276 ms
104,668 KB
testcase_96 AC 1,247 ms
104,084 KB
testcase_97 AC 1,242 ms
103,724 KB
testcase_98 AC 1,197 ms
104,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_389
import sys

mod=10**9+7
n=10**6
fact=[0 for i in xrange(n+1)]
inv=[0 for i in xrange(n+1)]
factr=[0 for i in xrange(n+1)]
inv[1]=fact[0]=factr[0]=1
for i in xrange(2,n+1):
 inv[i]=inv[mod%i]*(mod-mod/i)%mod
for i in xrange(1,n+1):
 fact[i]=fact[i-1]*i%mod
 factr[i]=factr[i-1]*inv[i]%mod

def comb(n,k):
 if k<0 or k>n: return 0
 return factr[k]*fact[n]%mod*factr[n-k]%mod
def perm(n,k):
 if k<0 or k>n: return 0
 return fact[n]*factr[n-k]%mod
def hcomb(n,k):
 if n==0 and k==0: return 1
 return comb(n+k-1,k)
 
m=int(raw_input())
h=map(int,raw_input().split())
if h[0]==0:
 print 1
 sys.exit()
if m-sum(h)-len(h)+1<0:
 print "NA"
 sys.exit()
k=len(h)
print hcomb(k+1,m-sum(h)-(k-1))
0