結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,272 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,400 KB
testcase_03 AC 11 ms
6,272 KB
testcase_04 AC 11 ms
6,400 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 124 ms
10,692 KB
testcase_10 AC 96 ms
9,600 KB
testcase_11 AC 185 ms
12,480 KB
testcase_12 AC 21 ms
6,912 KB
testcase_13 AC 73 ms
9,136 KB
testcase_14 AC 55 ms
7,644 KB
testcase_15 AC 58 ms
8,320 KB
testcase_16 AC 85 ms
9,216 KB
testcase_17 AC 169 ms
12,060 KB
testcase_18 AC 126 ms
11,160 KB
testcase_19 AC 11 ms
6,272 KB
testcase_20 AC 11 ms
6,400 KB
testcase_21 AC 11 ms
6,400 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,400 KB
testcase_26 AC 11 ms
6,272 KB
testcase_27 AC 12 ms
6,400 KB
testcase_28 AC 11 ms
6,400 KB
testcase_29 AC 11 ms
6,144 KB
testcase_30 AC 11 ms
6,400 KB
testcase_31 AC 11 ms
6,272 KB
testcase_32 AC 12 ms
6,400 KB
testcase_33 AC 11 ms
6,400 KB
testcase_34 AC 12 ms
6,400 KB
testcase_35 AC 11 ms
6,272 KB
testcase_36 AC 11 ms
6,272 KB
testcase_37 AC 11 ms
6,400 KB
testcase_38 AC 12 ms
6,400 KB
testcase_39 AC 12 ms
6,400 KB
testcase_40 AC 11 ms
6,400 KB
testcase_41 AC 11 ms
6,400 KB
testcase_42 AC 12 ms
6,400 KB
testcase_43 AC 11 ms
6,272 KB
testcase_44 AC 11 ms
6,272 KB
testcase_45 AC 11 ms
6,400 KB
testcase_46 AC 11 ms
6,400 KB
testcase_47 AC 11 ms
6,144 KB
testcase_48 AC 11 ms
6,400 KB
testcase_49 AC 133 ms
11,648 KB
testcase_50 AC 18 ms
7,168 KB
testcase_51 AC 17 ms
6,656 KB
testcase_52 AC 34 ms
9,600 KB
testcase_53 AC 22 ms
6,912 KB
testcase_54 AC 38 ms
10,240 KB
testcase_55 AC 12 ms
6,528 KB
testcase_56 AC 20 ms
6,912 KB
testcase_57 AC 63 ms
8,672 KB
testcase_58 AC 112 ms
10,728 KB
testcase_59 AC 87 ms
9,588 KB
testcase_60 AC 45 ms
7,800 KB
testcase_61 AC 175 ms
13,384 KB
testcase_62 AC 47 ms
7,936 KB
testcase_63 AC 115 ms
10,808 KB
testcase_64 AC 38 ms
9,728 KB
testcase_65 AC 28 ms
7,040 KB
testcase_66 AC 42 ms
7,680 KB
testcase_67 AC 40 ms
8,064 KB
testcase_68 AC 40 ms
10,112 KB
testcase_69 AC 12 ms
6,400 KB
testcase_70 AC 11 ms
6,400 KB
testcase_71 AC 11 ms
6,400 KB
testcase_72 AC 11 ms
6,272 KB
testcase_73 AC 11 ms
6,272 KB
testcase_74 AC 11 ms
6,400 KB
testcase_75 AC 12 ms
6,272 KB
testcase_76 AC 11 ms
6,272 KB
testcase_77 AC 11 ms
6,272 KB
testcase_78 AC 11 ms
6,272 KB
testcase_79 AC 11 ms
6,400 KB
testcase_80 AC 11 ms
6,400 KB
testcase_81 AC 11 ms
6,272 KB
testcase_82 AC 11 ms
6,400 KB
testcase_83 AC 11 ms
6,272 KB
testcase_84 AC 11 ms
6,400 KB
testcase_85 AC 11 ms
6,400 KB
testcase_86 AC 11 ms
6,400 KB
testcase_87 AC 11 ms
6,400 KB
testcase_88 AC 12 ms
6,400 KB
testcase_89 AC 51 ms
8,052 KB
testcase_90 AC 78 ms
9,444 KB
testcase_91 AC 130 ms
11,496 KB
testcase_92 AC 28 ms
7,168 KB
testcase_93 AC 86 ms
9,536 KB
testcase_94 AC 12 ms
6,400 KB
testcase_95 AC 89 ms
9,484 KB
testcase_96 AC 71 ms
9,104 KB
testcase_97 AC 67 ms
8,948 KB
testcase_98 AC 39 ms
9,728 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()
print ncr(len(H)+blank, blank)
0