結果

問題 No.1989 Pairing Multiset
ユーザー kyskys
提出日時 2022-06-25 01:19:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,359 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 60,288 KB
最終ジャッジ日時 2024-04-26 06:49:11
合計ジャッジ時間 2,041 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 66 ms
60,288 KB
testcase_04 WA -
testcase_05 AC 39 ms
54,272 KB
testcase_06 AC 40 ms
54,400 KB
testcase_07 WA -
testcase_08 WA -
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 AC 41 ms
53,888 KB
testcase_19 WA -
testcase_20 AC 69 ms
59,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import combinations_with_replacement
import sys
input = sys.stdin.readline
def iinput(): return int(input())
def sinput(): return input().rstrip()
def i0input(): return int(input()) - 1
def linput(): return list(input().split())
def liinput(): return list(map(int, input().split()))
def miinput(): return map(int, input().split())
def li0input(): return list(map(lambda x: int(x) - 1, input().split()))
def mi0input(): return map(lambda x: int(x) - 1, input().split())
INF = 10**20
MOD = 1000000007

def modinv(a):
    b = MOD
    u, v = 1, 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    return u % MOD
 
def combi(n, k):
    k = max(k, n-k)
    ans = 1
    for i in range(n, k, -1):
        ans *= i
        ans %= MOD
    tmp = 1
    for i in range(2, n-k+1):
        tmp *= i
        tmp %= MOD
    return ans * modinv(tmp) % MOD

def solve_naive(N, M):
    ans = 0
    for res in combinations_with_replacement(range(M+1), 2*N):
        tmp = 0
        for i in range(N):
            tmp += abs(res[2*i] - res[2*i+1])
        ans += tmp
    return ans

def solve_naive2(N, M):
    ans = 0
    for k in range(M+1):
        ans += k * combi(k+N-1, k) * combi(M+N-k, M-k)
    return ans

N, M = liinput()
print(combi(2*N+M, 2*N+1) * N)
0