結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー HachimoriHachimori
提出日時 2016-07-09 15:45:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 7,324 KB
実行使用メモリ 27,352 KB
最終ジャッジ日時 2024-04-21 10:43:28
合計ジャッジ時間 6,394 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,400 KB
testcase_01 AC 11 ms
6,272 KB
testcase_02 AC 11 ms
6,400 KB
testcase_03 AC 11 ms
6,400 KB
testcase_04 AC 165 ms
27,228 KB
testcase_05 AC 11 ms
6,272 KB
testcase_06 AC 11 ms
6,272 KB
testcase_07 AC 11 ms
6,528 KB
testcase_08 AC 11 ms
6,400 KB
testcase_09 AC 181 ms
27,352 KB
testcase_10 AC 34 ms
8,316 KB
testcase_11 AC 179 ms
26,888 KB
testcase_12 AC 21 ms
6,912 KB
testcase_13 AC 74 ms
9,256 KB
testcase_14 AC 35 ms
7,424 KB
testcase_15 AC 38 ms
9,344 KB
testcase_16 AC 85 ms
15,516 KB
testcase_17 AC 126 ms
19,992 KB
testcase_18 AC 125 ms
11,284 KB
testcase_19 AC 12 ms
6,400 KB
testcase_20 AC 12 ms
6,400 KB
testcase_21 AC 12 ms
6,528 KB
testcase_22 AC 12 ms
6,400 KB
testcase_23 AC 11 ms
6,400 KB
testcase_24 AC 11 ms
6,400 KB
testcase_25 AC 11 ms
6,272 KB
testcase_26 AC 12 ms
6,400 KB
testcase_27 AC 11 ms
6,400 KB
testcase_28 AC 11 ms
6,400 KB
testcase_29 AC 11 ms
6,400 KB
testcase_30 AC 11 ms
6,272 KB
testcase_31 AC 11 ms
6,528 KB
testcase_32 AC 11 ms
6,400 KB
testcase_33 AC 12 ms
6,400 KB
testcase_34 AC 11 ms
6,400 KB
testcase_35 AC 11 ms
6,400 KB
testcase_36 AC 12 ms
6,400 KB
testcase_37 AC 12 ms
6,400 KB
testcase_38 AC 12 ms
6,400 KB
testcase_39 AC 11 ms
6,272 KB
testcase_40 AC 12 ms
6,272 KB
testcase_41 AC 12 ms
6,400 KB
testcase_42 AC 12 ms
6,400 KB
testcase_43 AC 11 ms
6,272 KB
testcase_44 AC 12 ms
6,400 KB
testcase_45 AC 11 ms
6,400 KB
testcase_46 AC 12 ms
6,400 KB
testcase_47 AC 11 ms
6,528 KB
testcase_48 AC 12 ms
6,272 KB
testcase_49 AC 133 ms
11,592 KB
testcase_50 AC 19 ms
7,296 KB
testcase_51 AC 18 ms
6,656 KB
testcase_52 AC 33 ms
9,472 KB
testcase_53 AC 21 ms
7,040 KB
testcase_54 AC 39 ms
10,112 KB
testcase_55 AC 13 ms
6,400 KB
testcase_56 AC 20 ms
6,656 KB
testcase_57 AC 63 ms
8,668 KB
testcase_58 AC 111 ms
10,724 KB
testcase_59 AC 89 ms
9,712 KB
testcase_60 AC 45 ms
7,792 KB
testcase_61 AC 178 ms
13,448 KB
testcase_62 AC 47 ms
8,064 KB
testcase_63 AC 114 ms
10,804 KB
testcase_64 AC 39 ms
9,984 KB
testcase_65 AC 28 ms
7,168 KB
testcase_66 AC 42 ms
7,808 KB
testcase_67 AC 41 ms
8,064 KB
testcase_68 AC 40 ms
10,368 KB
testcase_69 AC 93 ms
17,576 KB
testcase_70 AC 47 ms
11,632 KB
testcase_71 AC 71 ms
14,576 KB
testcase_72 AC 35 ms
9,600 KB
testcase_73 AC 56 ms
12,544 KB
testcase_74 AC 75 ms
15,104 KB
testcase_75 AC 69 ms
14,016 KB
testcase_76 AC 31 ms
9,088 KB
testcase_77 AC 122 ms
21,444 KB
testcase_78 AC 16 ms
7,040 KB
testcase_79 AC 12 ms
6,400 KB
testcase_80 AC 11 ms
6,272 KB
testcase_81 AC 12 ms
6,272 KB
testcase_82 AC 11 ms
6,400 KB
testcase_83 AC 12 ms
6,400 KB
testcase_84 AC 11 ms
6,400 KB
testcase_85 AC 12 ms
6,400 KB
testcase_86 AC 11 ms
6,400 KB
testcase_87 AC 11 ms
6,272 KB
testcase_88 AC 11 ms
6,528 KB
testcase_89 AC 52 ms
8,044 KB
testcase_90 AC 79 ms
9,312 KB
testcase_91 AC 130 ms
11,364 KB
testcase_92 AC 29 ms
7,168 KB
testcase_93 AC 85 ms
9,536 KB
testcase_94 AC 13 ms
6,528 KB
testcase_95 AC 92 ms
9,736 KB
testcase_96 AC 72 ms
8,972 KB
testcase_97 AC 68 ms
8,944 KB
testcase_98 AC 40 ms
9,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

MOD = 1000000007


def read():
    M = input()
    hList = map(int, raw_input().split())
    return M, hList


def mypow(p, n):
    if n == 0:
        return 1
    t = mypow(p, n / 2)
    return t * t % MOD if n % 2 == 0 else t * t * p % MOD
    

def nCk(n, k):
    nume = 1
    for i in range(k):
        nume = nume * (n - i) % MOD
    
    deno = 1
    for i in range(k):
        deno = deno * (i + 1) % MOD
    
    return nume * mypow(deno, MOD - 2) % MOD


def nHk(n, k):
    return nCk(n + k - 1, k)


def work((M, hList)):
    if sum(hList) == 0:
        print 1
        return
    
    N = len(hList) + 1
    K = M - sum(hList) - (len(hList) - 1)
    
    if K < 0:
        print "NA"
    else:
        print nHk(N, K)


if __name__ == "__main__":
    work(read())
0