結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-08-10 03:18:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 84,608 KB
最終ジャッジ日時 2024-04-15 20:28:58
合計ジャッジ時間 12,441 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 WA -
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 28 ms
10,880 KB
testcase_04 AC 413 ms
62,208 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 421 ms
65,364 KB
testcase_10 AC 83 ms
18,136 KB
testcase_11 AC 426 ms
66,160 KB
testcase_12 AC 48 ms
12,896 KB
testcase_13 AC 159 ms
25,372 KB
testcase_14 AC 79 ms
16,564 KB
testcase_15 AC 93 ms
19,456 KB
testcase_16 AC 207 ms
35,400 KB
testcase_17 AC 302 ms
48,084 KB
testcase_18 AC 267 ms
37,372 KB
testcase_19 AC 29 ms
11,008 KB
testcase_20 AC 28 ms
10,880 KB
testcase_21 AC 29 ms
11,008 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 29 ms
10,880 KB
testcase_24 AC 30 ms
10,880 KB
testcase_25 AC 29 ms
11,008 KB
testcase_26 AC 29 ms
10,880 KB
testcase_27 AC 30 ms
11,008 KB
testcase_28 AC 30 ms
11,008 KB
testcase_29 AC 29 ms
11,008 KB
testcase_30 AC 29 ms
10,880 KB
testcase_31 AC 30 ms
11,008 KB
testcase_32 AC 30 ms
10,880 KB
testcase_33 AC 29 ms
10,880 KB
testcase_34 AC 30 ms
10,880 KB
testcase_35 AC 29 ms
11,008 KB
testcase_36 AC 29 ms
10,880 KB
testcase_37 AC 31 ms
11,008 KB
testcase_38 AC 29 ms
10,880 KB
testcase_39 AC 29 ms
10,880 KB
testcase_40 AC 29 ms
10,880 KB
testcase_41 AC 29 ms
11,008 KB
testcase_42 AC 29 ms
10,880 KB
testcase_43 AC 31 ms
10,880 KB
testcase_44 AC 29 ms
11,008 KB
testcase_45 AC 29 ms
10,880 KB
testcase_46 AC 29 ms
11,008 KB
testcase_47 AC 28 ms
11,008 KB
testcase_48 AC 29 ms
10,880 KB
testcase_49 AC 95 ms
16,672 KB
testcase_50 AC 34 ms
11,904 KB
testcase_51 AC 30 ms
11,264 KB
testcase_52 AC 43 ms
14,284 KB
testcase_53 AC 35 ms
11,648 KB
testcase_54 AC 46 ms
14,940 KB
testcase_55 AC 29 ms
10,880 KB
testcase_56 AC 35 ms
11,392 KB
testcase_57 AC 57 ms
13,628 KB
testcase_58 AC 87 ms
15,556 KB
testcase_59 AC 70 ms
14,172 KB
testcase_60 AC 47 ms
12,328 KB
testcase_61 AC 118 ms
18,688 KB
testcase_62 AC 48 ms
12,572 KB
testcase_63 AC 87 ms
16,028 KB
testcase_64 AC 46 ms
14,448 KB
testcase_65 AC 39 ms
11,648 KB
testcase_66 AC 44 ms
12,252 KB
testcase_67 AC 45 ms
12,516 KB
testcase_68 AC 46 ms
14,848 KB
testcase_69 AC 229 ms
38,528 KB
testcase_70 AC 120 ms
23,808 KB
testcase_71 AC 174 ms
31,360 KB
testcase_72 AC 88 ms
19,200 KB
testcase_73 AC 139 ms
26,112 KB
testcase_74 AC 187 ms
32,512 KB
testcase_75 AC 166 ms
29,824 KB
testcase_76 AC 77 ms
17,664 KB
testcase_77 AC 297 ms
48,256 KB
testcase_78 AC 42 ms
12,544 KB
testcase_79 AC 29 ms
11,008 KB
testcase_80 AC 29 ms
10,880 KB
testcase_81 AC 29 ms
11,008 KB
testcase_82 AC 29 ms
11,008 KB
testcase_83 AC 29 ms
11,008 KB
testcase_84 AC 29 ms
11,008 KB
testcase_85 AC 28 ms
10,880 KB
testcase_86 AC 28 ms
10,880 KB
testcase_87 AC 28 ms
11,008 KB
testcase_88 AC 30 ms
10,880 KB
testcase_89 AC 110 ms
19,996 KB
testcase_90 AC 162 ms
26,336 KB
testcase_91 AC 263 ms
38,932 KB
testcase_92 AC 60 ms
14,688 KB
testcase_93 AC 181 ms
28,404 KB
testcase_94 AC 31 ms
11,136 KB
testcase_95 AC 192 ms
28,772 KB
testcase_96 AC 153 ms
25,004 KB
testcase_97 AC 144 ms
24,140 KB
testcase_98 AC 84 ms
16,792 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 M >= 0:
    c = Combi(M, mod)
    print(c.C(M, L))
else:
    print("NA")
0