結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | realDivineJK |
提出日時 | 2020-05-19 16:17:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 762 ms / 2,000 ms |
コード長 | 910 bytes |
コンパイル時間 | 76 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 84,608 KB |
最終ジャッジ日時 | 2024-04-09 22:17:35 |
合計ジャッジ時間 | 13,419 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
11,008 KB |
testcase_01 | AC | 34 ms
11,776 KB |
testcase_02 | AC | 26 ms
10,880 KB |
testcase_03 | AC | 26 ms
10,880 KB |
testcase_04 | AC | 526 ms
62,208 KB |
testcase_05 | AC | 86 ms
17,536 KB |
testcase_06 | AC | 309 ms
40,704 KB |
testcase_07 | AC | 762 ms
84,608 KB |
testcase_08 | AC | 322 ms
43,136 KB |
testcase_09 | AC | 601 ms
65,312 KB |
testcase_10 | AC | 103 ms
18,136 KB |
testcase_11 | AC | 542 ms
66,240 KB |
testcase_12 | AC | 49 ms
12,904 KB |
testcase_13 | AC | 177 ms
25,028 KB |
testcase_14 | AC | 87 ms
16,436 KB |
testcase_15 | AC | 111 ms
19,456 KB |
testcase_16 | AC | 247 ms
35,272 KB |
testcase_17 | AC | 396 ms
48,088 KB |
testcase_18 | AC | 336 ms
37,384 KB |
testcase_19 | AC | 26 ms
10,880 KB |
testcase_20 | AC | 25 ms
10,880 KB |
testcase_21 | AC | 25 ms
10,880 KB |
testcase_22 | AC | 24 ms
10,880 KB |
testcase_23 | AC | 24 ms
10,880 KB |
testcase_24 | AC | 25 ms
11,008 KB |
testcase_25 | AC | 25 ms
10,880 KB |
testcase_26 | AC | 26 ms
10,880 KB |
testcase_27 | AC | 24 ms
10,880 KB |
testcase_28 | AC | 25 ms
10,880 KB |
testcase_29 | AC | 24 ms
10,880 KB |
testcase_30 | AC | 25 ms
10,880 KB |
testcase_31 | AC | 24 ms
10,880 KB |
testcase_32 | AC | 24 ms
11,008 KB |
testcase_33 | AC | 24 ms
10,880 KB |
testcase_34 | AC | 25 ms
10,880 KB |
testcase_35 | AC | 25 ms
10,880 KB |
testcase_36 | AC | 24 ms
11,008 KB |
testcase_37 | AC | 25 ms
10,880 KB |
testcase_38 | AC | 24 ms
11,008 KB |
testcase_39 | AC | 25 ms
10,880 KB |
testcase_40 | AC | 25 ms
11,008 KB |
testcase_41 | AC | 24 ms
10,880 KB |
testcase_42 | AC | 25 ms
10,880 KB |
testcase_43 | AC | 24 ms
11,008 KB |
testcase_44 | AC | 24 ms
10,880 KB |
testcase_45 | AC | 25 ms
10,880 KB |
testcase_46 | AC | 25 ms
11,008 KB |
testcase_47 | AC | 26 ms
11,008 KB |
testcase_48 | AC | 24 ms
10,880 KB |
testcase_49 | AC | 83 ms
16,820 KB |
testcase_50 | AC | 30 ms
11,776 KB |
testcase_51 | AC | 30 ms
11,136 KB |
testcase_52 | AC | 40 ms
14,160 KB |
testcase_53 | AC | 31 ms
11,520 KB |
testcase_54 | AC | 41 ms
14,692 KB |
testcase_55 | AC | 26 ms
10,880 KB |
testcase_56 | AC | 29 ms
11,264 KB |
testcase_57 | AC | 49 ms
13,332 KB |
testcase_58 | AC | 72 ms
15,568 KB |
testcase_59 | AC | 60 ms
14,172 KB |
testcase_60 | AC | 40 ms
12,328 KB |
testcase_61 | AC | 105 ms
18,608 KB |
testcase_62 | AC | 41 ms
12,576 KB |
testcase_63 | AC | 73 ms
16,028 KB |
testcase_64 | AC | 38 ms
14,460 KB |
testcase_65 | AC | 33 ms
11,648 KB |
testcase_66 | AC | 39 ms
12,256 KB |
testcase_67 | AC | 38 ms
12,644 KB |
testcase_68 | AC | 42 ms
14,720 KB |
testcase_69 | AC | 277 ms
38,528 KB |
testcase_70 | AC | 144 ms
23,808 KB |
testcase_71 | AC | 228 ms
31,232 KB |
testcase_72 | AC | 104 ms
19,200 KB |
testcase_73 | AC | 171 ms
26,240 KB |
testcase_74 | AC | 250 ms
32,640 KB |
testcase_75 | AC | 213 ms
29,952 KB |
testcase_76 | AC | 94 ms
17,536 KB |
testcase_77 | AC | 388 ms
48,256 KB |
testcase_78 | AC | 44 ms
12,544 KB |
testcase_79 | AC | 27 ms
10,880 KB |
testcase_80 | AC | 26 ms
10,880 KB |
testcase_81 | AC | 26 ms
11,008 KB |
testcase_82 | AC | 26 ms
10,880 KB |
testcase_83 | AC | 25 ms
10,880 KB |
testcase_84 | AC | 25 ms
10,880 KB |
testcase_85 | AC | 25 ms
10,880 KB |
testcase_86 | AC | 25 ms
10,880 KB |
testcase_87 | AC | 25 ms
10,880 KB |
testcase_88 | AC | 25 ms
10,880 KB |
testcase_89 | AC | 126 ms
20,000 KB |
testcase_90 | AC | 203 ms
26,360 KB |
testcase_91 | AC | 333 ms
38,356 KB |
testcase_92 | AC | 66 ms
14,696 KB |
testcase_93 | AC | 221 ms
27,932 KB |
testcase_94 | AC | 29 ms
11,008 KB |
testcase_95 | AC | 228 ms
28,772 KB |
testcase_96 | AC | 185 ms
24,744 KB |
testcase_97 | AC | 174 ms
24,152 KB |
testcase_98 | AC | 91 ms
16,504 KB |
ソースコード
M = int(input()) H = list(map(int, input().split())) K = len(H) S = sum(H) mod = int(1e9) + 7 maxf = M - S + 1 # <-- input factional limitation def doubling(n, m): y = 1 base = n tmp = m while tmp != 0: if tmp % 2 == 1: y *= base y %= mod base *= base base %= mod tmp //= 2 return y def inved(a): x, y, u, v, k, l = 1, 0, 0, 1, a, mod while l != 0: x, y, u, v = u, v, x - u * (k // l), y - v * (k // l) k, l = l, k % l return x % mod fact = [1 for _ in range(maxf+1)] invf = [1 for _ in range(maxf+1)] for i in range(maxf): fact[i+1] = (fact[i] * (i+1)) % mod invf[-1] = inved(fact[-1]) for i in range(maxf, 0, -1): invf[i-1] = (invf[i] * i) % mod if H == [0]: print(1) else: if S + K - 1 > M: print("NA") else: print((fact[M-S+1] * invf[K] * invf[M-S-K+1]) % mod)