結果

問題 No.1186 長方形の敷き詰め
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-07-01 20:47:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 259,460 KB
最終ジャッジ日時 2023-09-10 18:56:00
合計ジャッジ時間 4,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,304 KB
testcase_01 AC 74 ms
71,072 KB
testcase_02 AC 73 ms
71,256 KB
testcase_03 AC 71 ms
71,356 KB
testcase_04 AC 71 ms
71,132 KB
testcase_05 AC 71 ms
71,204 KB
testcase_06 AC 70 ms
71,480 KB
testcase_07 AC 72 ms
71,080 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 71 ms
71,388 KB
testcase_12 AC 72 ms
71,076 KB
testcase_13 AC 72 ms
71,524 KB
testcase_14 AC 73 ms
71,128 KB
testcase_15 AC 71 ms
71,336 KB
testcase_16 AC 78 ms
76,132 KB
testcase_17 AC 70 ms
71,028 KB
testcase_18 AC 72 ms
71,260 KB
testcase_19 AC 72 ms
71,504 KB
testcase_20 AC 72 ms
71,448 KB
testcase_21 AC 72 ms
71,280 KB
testcase_22 AC 348 ms
259,460 KB
testcase_23 AC 200 ms
202,096 KB
testcase_24 AC 257 ms
258,952 KB
testcase_25 AC 190 ms
188,952 KB
testcase_26 AC 204 ms
203,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
mod=998244353
if m<n:
  print(1)
  exit()
def cmb(n,r,mod=mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return (g1[n]*g2[r]*g2[n-r])%mod
g1=[1,1] # g1[i]=i! % mod :階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod :階乗の逆元
inverse=[0,1]
for i in range(2,m+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

ans=1
for i in range(1,m//n+1):
  # ピースを横におくブロックをi個
  t=m-n*i
  ans+=cmb(m-i*(n-1),i)
  ans%=mod
print(ans)


0