結果

問題 No.1832 NAND Reversible
ユーザー s1230149s1230149
提出日時 2022-07-07 13:33:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 125,808 KB
最終ジャッジ日時 2023-08-25 22:50:31
合計ジャッジ時間 39,298 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1,345 ms
125,704 KB
testcase_03 AC 1,508 ms
125,808 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,331 ms
125,800 KB
testcase_07 AC 1,463 ms
125,756 KB
testcase_08 AC 1,471 ms
125,624 KB
testcase_09 WA -
testcase_10 AC 1,359 ms
125,668 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,301 ms
125,796 KB
testcase_14 AC 1,358 ms
125,760 KB
testcase_15 AC 1,370 ms
125,608 KB
testcase_16 AC 1,374 ms
125,612 KB
testcase_17 AC 1,498 ms
125,696 KB
testcase_18 AC 1,364 ms
125,676 KB
testcase_19 AC 1,349 ms
125,680 KB
testcase_20 AC 1,321 ms
125,616 KB
testcase_21 AC 1,461 ms
125,608 KB
testcase_22 AC 1,453 ms
125,716 KB
testcase_23 WA -
testcase_24 AC 1,328 ms
125,672 KB
testcase_25 AC 1,412 ms
125,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

N, K = map(int, input().split())
K = N - K
# number of 1
mod = 998244353
ans = 0
for i in range(K+1):
    if i%2 == 1: continue
    if N - i - 1 == 0: ans += i + 1
    if N - i - 2 < 0: continue
    a = i + 1
    b = cmb((N - i - 2), K - i, p)
    ans += a * b
    ans %= mod
print(ans%mod)
0