結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-08-10 03:21:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 66,252 KB
最終ジャッジ日時 2024-04-15 20:29:10
合計ジャッジ時間 10,576 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
11,008 KB
testcase_01 AC 29 ms
11,008 KB
testcase_02 AC 29 ms
11,008 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 399 ms
62,208 KB
testcase_05 AC 29 ms
10,880 KB
testcase_06 AC 30 ms
11,008 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 30 ms
11,008 KB
testcase_09 AC 433 ms
65,324 KB
testcase_10 AC 84 ms
18,276 KB
testcase_11 AC 437 ms
66,252 KB
testcase_12 AC 48 ms
13,004 KB
testcase_13 AC 164 ms
25,168 KB
testcase_14 AC 79 ms
16,452 KB
testcase_15 AC 94 ms
19,456 KB
testcase_16 AC 205 ms
35,292 KB
testcase_17 AC 304 ms
48,100 KB
testcase_18 AC 271 ms
37,388 KB
testcase_19 AC 29 ms
10,880 KB
testcase_20 AC 30 ms
10,880 KB
testcase_21 AC 30 ms
11,008 KB
testcase_22 AC 29 ms
10,880 KB
testcase_23 AC 28 ms
10,880 KB
testcase_24 AC 29 ms
10,880 KB
testcase_25 AC 28 ms
11,008 KB
testcase_26 AC 30 ms
11,008 KB
testcase_27 AC 29 ms
11,008 KB
testcase_28 AC 29 ms
10,880 KB
testcase_29 AC 28 ms
10,880 KB
testcase_30 AC 28 ms
10,880 KB
testcase_31 AC 28 ms
11,008 KB
testcase_32 AC 27 ms
10,880 KB
testcase_33 AC 28 ms
11,008 KB
testcase_34 AC 27 ms
11,008 KB
testcase_35 AC 28 ms
11,008 KB
testcase_36 AC 29 ms
10,880 KB
testcase_37 AC 29 ms
10,880 KB
testcase_38 AC 28 ms
11,008 KB
testcase_39 AC 28 ms
10,880 KB
testcase_40 AC 29 ms
10,880 KB
testcase_41 AC 28 ms
11,008 KB
testcase_42 AC 28 ms
11,008 KB
testcase_43 AC 27 ms
10,880 KB
testcase_44 AC 29 ms
11,008 KB
testcase_45 AC 28 ms
10,880 KB
testcase_46 AC 29 ms
10,880 KB
testcase_47 AC 28 ms
10,880 KB
testcase_48 AC 29 ms
11,008 KB
testcase_49 AC 97 ms
16,800 KB
testcase_50 AC 33 ms
11,904 KB
testcase_51 AC 31 ms
11,136 KB
testcase_52 AC 44 ms
14,300 KB
testcase_53 AC 35 ms
11,648 KB
testcase_54 AC 47 ms
14,836 KB
testcase_55 AC 30 ms
10,880 KB
testcase_56 AC 35 ms
11,520 KB
testcase_57 AC 57 ms
13,344 KB
testcase_58 AC 90 ms
15,840 KB
testcase_59 AC 72 ms
14,188 KB
testcase_60 AC 49 ms
12,468 KB
testcase_61 AC 122 ms
18,752 KB
testcase_62 AC 49 ms
12,596 KB
testcase_63 AC 88 ms
16,088 KB
testcase_64 AC 47 ms
14,592 KB
testcase_65 AC 38 ms
11,648 KB
testcase_66 AC 47 ms
12,264 KB
testcase_67 AC 46 ms
12,536 KB
testcase_68 AC 49 ms
14,744 KB
testcase_69 AC 228 ms
38,528 KB
testcase_70 AC 121 ms
23,808 KB
testcase_71 AC 175 ms
31,232 KB
testcase_72 AC 90 ms
19,200 KB
testcase_73 AC 141 ms
26,112 KB
testcase_74 AC 184 ms
32,512 KB
testcase_75 AC 168 ms
29,824 KB
testcase_76 AC 76 ms
17,536 KB
testcase_77 AC 292 ms
48,384 KB
testcase_78 AC 40 ms
12,800 KB
testcase_79 AC 29 ms
10,880 KB
testcase_80 AC 29 ms
10,880 KB
testcase_81 AC 29 ms
10,880 KB
testcase_82 AC 29 ms
11,008 KB
testcase_83 AC 29 ms
11,008 KB
testcase_84 AC 29 ms
10,880 KB
testcase_85 AC 28 ms
11,008 KB
testcase_86 AC 29 ms
10,880 KB
testcase_87 AC 29 ms
11,008 KB
testcase_88 AC 29 ms
11,008 KB
testcase_89 AC 112 ms
20,016 KB
testcase_90 AC 169 ms
26,504 KB
testcase_91 AC 277 ms
38,496 KB
testcase_92 AC 65 ms
14,704 KB
testcase_93 AC 185 ms
27,936 KB
testcase_94 AC 32 ms
11,136 KB
testcase_95 AC 194 ms
28,912 KB
testcase_96 AC 153 ms
24,756 KB
testcase_97 AC 145 ms
23,832 KB
testcase_98 AC 85 ms
16,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def C(self, K, R):
        if K < R:
            return "NA"
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def P(self, K, R):
        if K < R:
            return "NA"
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod

mod =10**9 + 7
M = int(input())
H = list(map(int, input().split()))
L = len(H)
M += (L-sum(H))
M -= (L-1)

if sum(H)==0:
    print(1)
    exit()
if M >= 0:
    c = Combi(M, mod)
    print(c.C(M, L))
else:
    print("NA")
0