結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー vwxyzvwxyz
提出日時 2021-07-31 10:39:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,183 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 266,648 KB
最終ジャッジ日時 2023-10-14 14:35:56
合計ジャッジ時間 46,666 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 248 ms
91,148 KB
testcase_02 WA -
testcase_03 AC 248 ms
91,320 KB
testcase_04 WA -
testcase_05 AC 247 ms
90,968 KB
testcase_06 AC 255 ms
90,968 KB
testcase_07 AC 252 ms
91,200 KB
testcase_08 AC 258 ms
91,328 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 310 ms
147,544 KB
testcase_50 AC 254 ms
94,540 KB
testcase_51 AC 254 ms
94,804 KB
testcase_52 AC 269 ms
101,656 KB
testcase_53 AC 265 ms
96,988 KB
testcase_54 AC 267 ms
102,852 KB
testcase_55 AC 250 ms
91,960 KB
testcase_56 AC 257 ms
96,592 KB
testcase_57 AC 280 ms
116,548 KB
testcase_58 AC 305 ms
140,840 KB
testcase_59 AC 292 ms
126,404 KB
testcase_60 AC 268 ms
107,300 KB
testcase_61 AC 330 ms
170,256 KB
testcase_62 AC 275 ms
109,220 KB
testcase_63 AC 301 ms
141,244 KB
testcase_64 AC 266 ms
103,076 KB
testcase_65 AC 264 ms
99,548 KB
testcase_66 AC 274 ms
107,028 KB
testcase_67 AC 265 ms
105,904 KB
testcase_68 AC 262 ms
104,344 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD, modf
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

def Extended_Euclid(n,m):
    stack=[]
    while m:
        stack.append((n,m))
        n,m=m,n%m
    if n>=0:
        x,y=1,0
    else:
        x,y=-1,0
    for i in range(len(stack)-1,-1,-1):
        n,m=stack[i]
        x,y=y,x-(n//m)*y
    return x,y

class MOD:
    def __init__(self,mod):
        self.mod=mod
    
    def Pow(self,a,n):
        a%=self.mod
        if n>=0:
            return pow(a,n,self.mod)
        else:
            assert math.gcd(a,self.mod)==1
            x=Extended_Euclid(a,self.mod)[0]
            return pow(x,-n,self.mod)

    def Build_Fact(self,N):
        assert N>=0
        self.factorial=[1]
        for i in range(1,N+1):
            self.factorial.append((self.factorial[-1]*i)%self.mod)
        self.factorial_inv=[None]*(N+1)
        self.factorial_inv[-1]=self.Pow(self.factorial[-1],-1)
        for i in range(N-1,-1,-1):
            self.factorial_inv[i]=(self.factorial_inv[i+1]*(i+1))%self.mod
        return self.factorial_inv

    def Fact(self,N):
        return self.factorial[N]

    def Fact_Inv(self,N):
        return self.factorial_inv[N]

    def Comb(self,N,K):
        if K<0 or K>N:
            return 0
        s=self.factorial[N]
        s=(s*self.factorial_inv[K])%self.mod
        s=(s*self.factorial_inv[N-K])%self.mod
        return s

M,*H=map(int,read().split())
S=sum(H)+len(H)-1
if H==[0]:
    ans=1
elif S>M:
    ans='NA'
else:
    mod=10**9+7
    MD=MOD(mod)
    MD.Build_Fact(2*10**6)
    ans=MD.Comb(M-S+len(H),len(H))
    print(M,S)
print(ans)
0