結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー nebukuro09nebukuro09
提出日時 2016-10-25 14:48:11
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 13,460 KB
最終ジャッジ日時 2024-05-03 05:59:15
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,528 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,272 KB
testcase_03 AC 12 ms
6,400 KB
testcase_04 AC 12 ms
6,400 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 125 ms
10,696 KB
testcase_10 AC 92 ms
9,600 KB
testcase_11 AC 193 ms
12,608 KB
testcase_12 AC 21 ms
6,912 KB
testcase_13 AC 73 ms
9,260 KB
testcase_14 AC 56 ms
7,776 KB
testcase_15 AC 58 ms
8,320 KB
testcase_16 AC 86 ms
9,344 KB
testcase_17 AC 170 ms
11,932 KB
testcase_18 AC 127 ms
11,288 KB
testcase_19 AC 11 ms
6,400 KB
testcase_20 AC 11 ms
6,400 KB
testcase_21 AC 12 ms
6,400 KB
testcase_22 AC 11 ms
6,528 KB
testcase_23 AC 11 ms
6,400 KB
testcase_24 AC 11 ms
6,400 KB
testcase_25 AC 11 ms
6,400 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 12 ms
6,400 KB
testcase_31 AC 12 ms
6,400 KB
testcase_32 AC 12 ms
6,272 KB
testcase_33 AC 11 ms
6,400 KB
testcase_34 AC 12 ms
6,272 KB
testcase_35 AC 12 ms
6,528 KB
testcase_36 AC 12 ms
6,528 KB
testcase_37 AC 12 ms
6,528 KB
testcase_38 AC 13 ms
6,272 KB
testcase_39 AC 12 ms
6,400 KB
testcase_40 AC 12 ms
6,528 KB
testcase_41 AC 12 ms
6,528 KB
testcase_42 AC 12 ms
6,528 KB
testcase_43 AC 12 ms
6,400 KB
testcase_44 AC 12 ms
6,400 KB
testcase_45 AC 12 ms
6,400 KB
testcase_46 AC 11 ms
6,400 KB
testcase_47 AC 11 ms
6,400 KB
testcase_48 AC 11 ms
6,400 KB
testcase_49 AC 133 ms
11,724 KB
testcase_50 AC 18 ms
7,296 KB
testcase_51 AC 18 ms
6,784 KB
testcase_52 AC 34 ms
9,600 KB
testcase_53 AC 22 ms
7,040 KB
testcase_54 AC 39 ms
10,240 KB
testcase_55 AC 13 ms
6,528 KB
testcase_56 AC 21 ms
6,944 KB
testcase_57 AC 63 ms
8,544 KB
testcase_58 AC 111 ms
10,732 KB
testcase_59 AC 89 ms
9,716 KB
testcase_60 AC 46 ms
7,796 KB
testcase_61 AC 178 ms
13,460 KB
testcase_62 AC 48 ms
7,808 KB
testcase_63 AC 115 ms
10,932 KB
testcase_64 AC 38 ms
9,984 KB
testcase_65 AC 28 ms
7,040 KB
testcase_66 AC 42 ms
7,808 KB
testcase_67 AC 41 ms
8,064 KB
testcase_68 AC 40 ms
10,240 KB
testcase_69 AC 12 ms
6,272 KB
testcase_70 AC 12 ms
6,400 KB
testcase_71 AC 11 ms
6,400 KB
testcase_72 AC 11 ms
6,528 KB
testcase_73 AC 12 ms
6,400 KB
testcase_74 AC 12 ms
6,400 KB
testcase_75 AC 11 ms
6,272 KB
testcase_76 AC 11 ms
6,528 KB
testcase_77 AC 11 ms
6,528 KB
testcase_78 AC 12 ms
6,272 KB
testcase_79 AC 12 ms
6,528 KB
testcase_80 AC 12 ms
6,400 KB
testcase_81 AC 13 ms
6,528 KB
testcase_82 AC 12 ms
6,400 KB
testcase_83 AC 12 ms
6,272 KB
testcase_84 AC 12 ms
6,400 KB
testcase_85 AC 12 ms
6,400 KB
testcase_86 AC 11 ms
6,400 KB
testcase_87 AC 12 ms
6,272 KB
testcase_88 AC 11 ms
6,400 KB
testcase_89 AC 51 ms
8,052 KB
testcase_90 AC 78 ms
9,448 KB
testcase_91 AC 130 ms
11,372 KB
testcase_92 AC 28 ms
7,040 KB
testcase_93 AC 86 ms
9,540 KB
testcase_94 AC 13 ms
6,528 KB
testcase_95 AC 89 ms
9,740 KB
testcase_96 AC 72 ms
9,108 KB
testcase_97 AC 76 ms
8,816 KB
testcase_98 AC 41 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 1000000007

def ncr(n, r):
    if n - r < r:
        r = n-r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [0 for i in range(r)]
    denominator = [0 for i in range(r)]

    for k in range(r):
        numerator[k] = n - r + k + 1
        denominator[k] = k + 1
    
    for p in range(2, r+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (n-r) % p
        for k in range(p-1, r, p):
            numerator[k-offset] /= pivot
            denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result*numerator[k]) % MOD

    return result

M = input()
H = map(int, raw_input().split())
blank = M - sum(H) - len(H) + 1
if blank < 0:
    print 'NA'
    exit()
if M == 0:
    print 1
    exit()
print ncr(len(H)+blank, blank)
0