結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | mkawa2 |
提出日時 | 2020-04-15 00:41:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 546 ms / 2,000 ms |
コード長 | 2,190 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 335,016 KB |
最終ジャッジ日時 | 2024-10-01 18:29:35 |
合計ジャッジ時間 | 43,755 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 383 ms
255,648 KB |
testcase_01 | AC | 383 ms
255,812 KB |
testcase_02 | AC | 380 ms
255,644 KB |
testcase_03 | AC | 383 ms
256,288 KB |
testcase_04 | AC | 378 ms
255,784 KB |
testcase_05 | AC | 376 ms
255,648 KB |
testcase_06 | AC | 381 ms
255,648 KB |
testcase_07 | AC | 375 ms
256,036 KB |
testcase_08 | AC | 374 ms
256,040 KB |
testcase_09 | AC | 403 ms
259,364 KB |
testcase_10 | AC | 390 ms
257,948 KB |
testcase_11 | AC | 388 ms
261,536 KB |
testcase_12 | AC | 383 ms
257,312 KB |
testcase_13 | AC | 529 ms
292,896 KB |
testcase_14 | AC | 388 ms
262,048 KB |
testcase_15 | AC | 409 ms
256,420 KB |
testcase_16 | AC | 384 ms
258,080 KB |
testcase_17 | AC | 392 ms
261,152 KB |
testcase_18 | AC | 528 ms
314,396 KB |
testcase_19 | AC | 381 ms
255,772 KB |
testcase_20 | AC | 403 ms
255,504 KB |
testcase_21 | AC | 377 ms
255,612 KB |
testcase_22 | AC | 396 ms
256,156 KB |
testcase_23 | AC | 380 ms
256,164 KB |
testcase_24 | AC | 537 ms
255,648 KB |
testcase_25 | AC | 378 ms
256,036 KB |
testcase_26 | AC | 381 ms
255,644 KB |
testcase_27 | AC | 402 ms
256,032 KB |
testcase_28 | AC | 379 ms
255,652 KB |
testcase_29 | AC | 380 ms
255,768 KB |
testcase_30 | AC | 377 ms
255,520 KB |
testcase_31 | AC | 376 ms
256,032 KB |
testcase_32 | AC | 381 ms
255,520 KB |
testcase_33 | AC | 377 ms
255,520 KB |
testcase_34 | AC | 378 ms
255,868 KB |
testcase_35 | AC | 379 ms
255,772 KB |
testcase_36 | AC | 377 ms
256,036 KB |
testcase_37 | AC | 377 ms
255,524 KB |
testcase_38 | AC | 398 ms
255,520 KB |
testcase_39 | AC | 380 ms
255,912 KB |
testcase_40 | AC | 376 ms
255,644 KB |
testcase_41 | AC | 381 ms
255,644 KB |
testcase_42 | AC | 377 ms
256,096 KB |
testcase_43 | AC | 368 ms
256,032 KB |
testcase_44 | AC | 385 ms
255,636 KB |
testcase_45 | AC | 373 ms
255,908 KB |
testcase_46 | AC | 392 ms
256,028 KB |
testcase_47 | AC | 372 ms
255,516 KB |
testcase_48 | AC | 392 ms
255,520 KB |
testcase_49 | AC | 523 ms
315,040 KB |
testcase_50 | AC | 383 ms
255,780 KB |
testcase_51 | AC | 385 ms
256,408 KB |
testcase_52 | AC | 390 ms
261,628 KB |
testcase_53 | AC | 384 ms
257,564 KB |
testcase_54 | AC | 388 ms
263,324 KB |
testcase_55 | AC | 377 ms
255,896 KB |
testcase_56 | AC | 394 ms
257,560 KB |
testcase_57 | AC | 491 ms
287,900 KB |
testcase_58 | AC | 518 ms
308,896 KB |
testcase_59 | AC | 505 ms
296,228 KB |
testcase_60 | AC | 482 ms
278,048 KB |
testcase_61 | AC | 546 ms
335,016 KB |
testcase_62 | AC | 491 ms
279,844 KB |
testcase_63 | AC | 524 ms
309,536 KB |
testcase_64 | AC | 397 ms
263,196 KB |
testcase_65 | AC | 393 ms
260,124 KB |
testcase_66 | AC | 477 ms
277,536 KB |
testcase_67 | AC | 483 ms
276,252 KB |
testcase_68 | AC | 490 ms
274,212 KB |
testcase_69 | AC | 382 ms
255,776 KB |
testcase_70 | AC | 379 ms
255,904 KB |
testcase_71 | AC | 380 ms
255,776 KB |
testcase_72 | AC | 379 ms
256,160 KB |
testcase_73 | AC | 375 ms
255,520 KB |
testcase_74 | AC | 377 ms
255,648 KB |
testcase_75 | AC | 375 ms
255,520 KB |
testcase_76 | AC | 375 ms
255,780 KB |
testcase_77 | AC | 374 ms
256,032 KB |
testcase_78 | AC | 376 ms
255,644 KB |
testcase_79 | AC | 375 ms
256,028 KB |
testcase_80 | AC | 375 ms
255,648 KB |
testcase_81 | AC | 374 ms
256,028 KB |
testcase_82 | AC | 375 ms
255,780 KB |
testcase_83 | AC | 376 ms
255,676 KB |
testcase_84 | AC | 375 ms
256,156 KB |
testcase_85 | AC | 375 ms
256,156 KB |
testcase_86 | AC | 383 ms
256,284 KB |
testcase_87 | AC | 377 ms
255,652 KB |
testcase_88 | AC | 377 ms
256,164 KB |
testcase_89 | AC | 485 ms
282,400 KB |
testcase_90 | AC | 498 ms
293,460 KB |
testcase_91 | AC | 513 ms
314,404 KB |
testcase_92 | AC | 381 ms
261,148 KB |
testcase_93 | AC | 496 ms
296,212 KB |
testcase_94 | AC | 377 ms
255,892 KB |
testcase_95 | AC | 504 ms
299,812 KB |
testcase_96 | AC | 486 ms
290,596 KB |
testcase_97 | AC | 492 ms
290,208 KB |
testcase_98 | AC | 474 ms
274,080 KB |
ソースコード
from itertools import permutations import sys sys.setrecursionlimit(10 ** 6) from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] # grobalにmdを設定すること class mint: def __init__(self, x): self.__x = x % md def __str__(self): return str(self.__x) def __neg__(self): return mint(-self.__x) def __add__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x + other) def __sub__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x - other) def __rsub__(self, other): return mint(other - self.__x) def __mul__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * other) __radd__ = __add__ __rmul__ = __mul__ def __truediv__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * pow(other, md - 2, md)) def __rtruediv__(self, other): return mint(other * pow(self.__x, md - 2, md)) def __pow__(self, power, modulo=None): return mint(pow(self.__x, power, md)) md = 10**9+7 def nCr(com_n, com_r): if com_n < com_r: return 0 return fac[com_n] * ifac[com_r] * ifac[com_n - com_r] n_max = 1000005 fac = [mint(1)] for i in range(1, n_max + 1): fac.append(fac[-1] * i) ifac = [mint(1)] * (n_max + 1) ifac[n_max] /= fac[n_max] for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1) def main(): m=II() hh=LI() if hh[0]==0: print(1) exit() w=m-sum(hh) if w<len(hh)-1: print("NA") exit() print(nCr(w+1,len(hh))) main()