結果

問題 No.1832 NAND Reversible
ユーザー googol_S0googol_S0
提出日時 2022-02-04 21:59:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,303 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 110,172 KB
最終ジャッジ日時 2023-09-02 04:50:27
合計ジャッジ時間 5,324 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
99,540 KB
testcase_01 AC 116 ms
99,336 KB
testcase_02 WA -
testcase_03 AC 152 ms
100,876 KB
testcase_04 AC 115 ms
99,660 KB
testcase_05 AC 114 ms
99,332 KB
testcase_06 AC 134 ms
100,008 KB
testcase_07 AC 156 ms
103,996 KB
testcase_08 WA -
testcase_09 AC 112 ms
99,420 KB
testcase_10 AC 133 ms
100,488 KB
testcase_11 AC 110 ms
99,500 KB
testcase_12 AC 112 ms
99,504 KB
testcase_13 AC 112 ms
99,636 KB
testcase_14 AC 115 ms
99,416 KB
testcase_15 AC 159 ms
105,844 KB
testcase_16 AC 162 ms
108,796 KB
testcase_17 AC 148 ms
100,760 KB
testcase_18 AC 153 ms
100,712 KB
testcase_19 AC 152 ms
100,908 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 129 ms
99,900 KB
testcase_23 AC 112 ms
99,668 KB
testcase_24 AC 110 ms
99,332 KB
testcase_25 AC 165 ms
110,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
def cmb(n,r):
  if r<0 or r>n:
    return 0
  return ((g1[n]*g2[r]%mod)*g2[n-r])%mod
 
N=1000000
g1=[1]*(N+3)
for i in range(2,N+3):
  g1[i]=g1[i-1]*i%mod
g2=[0]*len(g1)
g2[-1]=pow(g1[-1],mod-2,mod)
for i in range(N+1,-1,-1):
  g2[i]=g2[i+1]*(i+1)%mod
inv=[0]*(N+3)
for i in range(1,N+3):
  inv[i]=g2[i]*g1[i-1]%mod
N,K=map(int,input().split())
if K==0:
  print(1)
  exit()
if K==1:
  if N&1:
    print(N-2)
  else:
    print(2)
  exit()
A,B=0,0
x,y=1,2
for i in range(2,N+1):
  if i&1:
    x+=y
    if x>=mod:
      x-=mod
    y+=1
  A=(A+x*cmb(N-2-i,K-3))%mod
for i in range(3,K+1):
  A=(A+cmb(N-1-i,K-i))%mod
x,y=1,2
N-=2
for i in range(2,N+1):
  if i&1:
    x+=y
    if x>=mod:
      x-=mod
    y+=1
  B=(B+x*cmb(N-2-i,K-3))%mod
for i in range(3,K+1):
  B=(B+cmb(N-1-i,K-i))%mod
print((A+B)%mod)
0