結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | mkawa2 |
提出日時 | 2020-04-15 00:41:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 505 ms / 2,000 ms |
コード長 | 2,190 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 334,964 KB |
最終ジャッジ日時 | 2024-04-09 18:26:19 |
合計ジャッジ時間 | 41,102 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 345 ms
256,160 KB |
testcase_01 | AC | 348 ms
256,056 KB |
testcase_02 | AC | 344 ms
256,288 KB |
testcase_03 | AC | 345 ms
255,900 KB |
testcase_04 | AC | 346 ms
255,904 KB |
testcase_05 | AC | 345 ms
255,772 KB |
testcase_06 | AC | 346 ms
256,416 KB |
testcase_07 | AC | 348 ms
256,532 KB |
testcase_08 | AC | 341 ms
256,156 KB |
testcase_09 | AC | 350 ms
259,364 KB |
testcase_10 | AC | 348 ms
257,700 KB |
testcase_11 | AC | 355 ms
261,916 KB |
testcase_12 | AC | 350 ms
257,312 KB |
testcase_13 | AC | 474 ms
293,404 KB |
testcase_14 | AC | 362 ms
262,304 KB |
testcase_15 | AC | 353 ms
256,420 KB |
testcase_16 | AC | 354 ms
257,952 KB |
testcase_17 | AC | 357 ms
261,160 KB |
testcase_18 | AC | 499 ms
314,524 KB |
testcase_19 | AC | 354 ms
255,900 KB |
testcase_20 | AC | 353 ms
256,032 KB |
testcase_21 | AC | 351 ms
256,160 KB |
testcase_22 | AC | 350 ms
255,900 KB |
testcase_23 | AC | 356 ms
256,160 KB |
testcase_24 | AC | 352 ms
256,032 KB |
testcase_25 | AC | 355 ms
256,416 KB |
testcase_26 | AC | 349 ms
256,180 KB |
testcase_27 | AC | 349 ms
256,312 KB |
testcase_28 | AC | 354 ms
256,032 KB |
testcase_29 | AC | 352 ms
255,908 KB |
testcase_30 | AC | 352 ms
256,036 KB |
testcase_31 | AC | 350 ms
256,572 KB |
testcase_32 | AC | 354 ms
256,284 KB |
testcase_33 | AC | 353 ms
256,184 KB |
testcase_34 | AC | 354 ms
256,032 KB |
testcase_35 | AC | 351 ms
255,784 KB |
testcase_36 | AC | 353 ms
255,900 KB |
testcase_37 | AC | 353 ms
256,028 KB |
testcase_38 | AC | 356 ms
256,044 KB |
testcase_39 | AC | 356 ms
256,032 KB |
testcase_40 | AC | 356 ms
256,156 KB |
testcase_41 | AC | 355 ms
256,668 KB |
testcase_42 | AC | 358 ms
256,028 KB |
testcase_43 | AC | 353 ms
256,188 KB |
testcase_44 | AC | 354 ms
256,160 KB |
testcase_45 | AC | 354 ms
256,292 KB |
testcase_46 | AC | 354 ms
256,160 KB |
testcase_47 | AC | 352 ms
255,912 KB |
testcase_48 | AC | 355 ms
255,904 KB |
testcase_49 | AC | 491 ms
315,188 KB |
testcase_50 | AC | 356 ms
256,568 KB |
testcase_51 | AC | 355 ms
256,404 KB |
testcase_52 | AC | 364 ms
262,560 KB |
testcase_53 | AC | 359 ms
258,336 KB |
testcase_54 | AC | 366 ms
263,580 KB |
testcase_55 | AC | 356 ms
256,156 KB |
testcase_56 | AC | 359 ms
257,704 KB |
testcase_57 | AC | 470 ms
288,288 KB |
testcase_58 | AC | 492 ms
309,408 KB |
testcase_59 | AC | 478 ms
296,728 KB |
testcase_60 | AC | 456 ms
278,308 KB |
testcase_61 | AC | 505 ms
334,964 KB |
testcase_62 | AC | 457 ms
280,096 KB |
testcase_63 | AC | 486 ms
309,664 KB |
testcase_64 | AC | 364 ms
263,196 KB |
testcase_65 | AC | 361 ms
260,388 KB |
testcase_66 | AC | 452 ms
277,920 KB |
testcase_67 | AC | 452 ms
276,768 KB |
testcase_68 | AC | 450 ms
274,464 KB |
testcase_69 | AC | 354 ms
256,036 KB |
testcase_70 | AC | 353 ms
256,668 KB |
testcase_71 | AC | 355 ms
255,904 KB |
testcase_72 | AC | 352 ms
256,544 KB |
testcase_73 | AC | 354 ms
256,292 KB |
testcase_74 | AC | 351 ms
255,904 KB |
testcase_75 | AC | 348 ms
256,156 KB |
testcase_76 | AC | 350 ms
255,900 KB |
testcase_77 | AC | 350 ms
256,040 KB |
testcase_78 | AC | 349 ms
256,420 KB |
testcase_79 | AC | 352 ms
256,664 KB |
testcase_80 | AC | 351 ms
256,160 KB |
testcase_81 | AC | 351 ms
256,032 KB |
testcase_82 | AC | 353 ms
255,904 KB |
testcase_83 | AC | 355 ms
256,188 KB |
testcase_84 | AC | 353 ms
255,908 KB |
testcase_85 | AC | 359 ms
256,660 KB |
testcase_86 | AC | 351 ms
255,780 KB |
testcase_87 | AC | 353 ms
256,160 KB |
testcase_88 | AC | 354 ms
255,912 KB |
testcase_89 | AC | 458 ms
282,784 KB |
testcase_90 | AC | 472 ms
293,280 KB |
testcase_91 | AC | 490 ms
314,916 KB |
testcase_92 | AC | 359 ms
261,152 KB |
testcase_93 | AC | 472 ms
296,864 KB |
testcase_94 | AC | 351 ms
256,160 KB |
testcase_95 | AC | 477 ms
300,316 KB |
testcase_96 | AC | 470 ms
291,104 KB |
testcase_97 | AC | 470 ms
290,844 KB |
testcase_98 | AC | 453 ms
274,972 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()