結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー airisairis
提出日時 2016-07-09 02:46:55
言語 Python2
(2.7.18)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 39,240 KB
最終ジャッジ日時 2024-04-21 09:10:20
合計ジャッジ時間 16,869 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
14,160 KB
testcase_01 AC 29 ms
14,376 KB
testcase_02 AC 23 ms
14,204 KB
testcase_03 AC 24 ms
14,080 KB
testcase_04 AC 231 ms
29,824 KB
testcase_05 AC 49 ms
16,256 KB
testcase_06 AC 145 ms
23,144 KB
testcase_07 AC 322 ms
36,724 KB
testcase_08 AC 149 ms
23,996 KB
testcase_09 AC 285 ms
33,344 KB
testcase_10 AC 73 ms
17,140 KB
testcase_11 AC 294 ms
33,660 KB
testcase_12 AC 52 ms
15,972 KB
testcase_13 AC 384 ms
38,412 KB
testcase_14 AC 91 ms
17,620 KB
testcase_15 AC 71 ms
17,552 KB
testcase_16 AC 140 ms
22,672 KB
testcase_17 AC 212 ms
27,676 KB
testcase_18 AC 347 ms
31,636 KB
testcase_19 AC 23 ms
14,156 KB
testcase_20 AC 24 ms
14,080 KB
testcase_21 AC 24 ms
14,208 KB
testcase_22 AC 25 ms
14,160 KB
testcase_23 AC 26 ms
14,164 KB
testcase_24 AC 24 ms
14,080 KB
testcase_25 AC 23 ms
14,124 KB
testcase_26 AC 24 ms
14,124 KB
testcase_27 AC 23 ms
14,208 KB
testcase_28 AC 22 ms
14,168 KB
testcase_29 AC 22 ms
14,168 KB
testcase_30 AC 22 ms
14,192 KB
testcase_31 AC 22 ms
14,208 KB
testcase_32 AC 22 ms
14,208 KB
testcase_33 AC 22 ms
14,200 KB
testcase_34 AC 23 ms
14,172 KB
testcase_35 AC 22 ms
14,080 KB
testcase_36 AC 22 ms
14,080 KB
testcase_37 AC 23 ms
14,208 KB
testcase_38 AC 22 ms
14,208 KB
testcase_39 AC 24 ms
14,192 KB
testcase_40 AC 23 ms
14,152 KB
testcase_41 AC 22 ms
14,120 KB
testcase_42 AC 23 ms
14,204 KB
testcase_43 AC 24 ms
14,080 KB
testcase_44 AC 23 ms
14,080 KB
testcase_45 AC 23 ms
14,144 KB
testcase_46 AC 22 ms
14,208 KB
testcase_47 AC 24 ms
14,120 KB
testcase_48 AC 23 ms
14,164 KB
testcase_49 AC 367 ms
32,704 KB
testcase_50 AC 87 ms
18,964 KB
testcase_51 AC 47 ms
15,872 KB
testcase_52 AC 291 ms
32,912 KB
testcase_53 AC 94 ms
18,896 KB
testcase_54 AC 346 ms
36,880 KB
testcase_55 AC 68 ms
17,760 KB
testcase_56 AC 48 ms
15,580 KB
testcase_57 AC 224 ms
26,136 KB
testcase_58 AC 401 ms
36,388 KB
testcase_59 AC 312 ms
31,812 KB
testcase_60 AC 133 ms
20,564 KB
testcase_61 AC 498 ms
39,240 KB
testcase_62 AC 218 ms
26,932 KB
testcase_63 AC 347 ms
32,384 KB
testcase_64 AC 314 ms
34,652 KB
testcase_65 AC 81 ms
17,784 KB
testcase_66 AC 113 ms
18,984 KB
testcase_67 AC 207 ms
26,756 KB
testcase_68 AC 340 ms
36,472 KB
testcase_69 AC 241 ms
30,640 KB
testcase_70 AC 177 ms
25,728 KB
testcase_71 AC 111 ms
21,168 KB
testcase_72 AC 280 ms
33,920 KB
testcase_73 AC 128 ms
22,016 KB
testcase_74 AC 120 ms
21,628 KB
testcase_75 AC 120 ms
21,632 KB
testcase_76 AC 173 ms
25,600 KB
testcase_77 AC 171 ms
25,664 KB
testcase_78 AC 77 ms
18,176 KB
testcase_79 AC 106 ms
20,480 KB
testcase_80 AC 75 ms
17,980 KB
testcase_81 AC 39 ms
15,232 KB
testcase_82 AC 270 ms
32,768 KB
testcase_83 AC 138 ms
22,912 KB
testcase_84 AC 81 ms
18,560 KB
testcase_85 AC 304 ms
35,328 KB
testcase_86 AC 269 ms
33,024 KB
testcase_87 AC 44 ms
15,816 KB
testcase_88 AC 25 ms
14,276 KB
testcase_89 AC 204 ms
24,940 KB
testcase_90 AC 390 ms
38,500 KB
testcase_91 AC 367 ms
33,384 KB
testcase_92 AC 98 ms
18,756 KB
testcase_93 AC 295 ms
31,092 KB
testcase_94 AC 219 ms
29,568 KB
testcase_95 AC 250 ms
26,504 KB
testcase_96 AC 380 ms
38,004 KB
testcase_97 AC 332 ms
34,544 KB
testcase_98 AC 305 ms
34,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = input()
H = map(int, raw_input().split())
H = filter(lambda x: x > 0, H)

ans = 0
mod = int(1e+9 + 7)
fact = [0] * (10**6 + 10)
fact[0] = 1

S = sum(H)
n = len(H)


def powmod(x, p):
  res = 1
  tmp = x
  while p > 0:
    if p & 1:
      res *= tmp
      res %= mod
    tmp = tmp * tmp
    tmp %= mod;
    p = p >> 1;
  return res


for i in xrange(M + 5):
  fact[i + 1] = (i + 1) * fact[i]
  fact[i + 1] %= mod;

if S + (n - 1) > M:
  print "NA"
else:
  a = fact[M - S + 1]
  b = fact[n]
  c = fact[M - S + 1 - n]

  ans = a * powmod((b * c) % mod, mod - 2)
  ans %= mod

  print ans

0