結果

問題 No.1186 長方形の敷き詰め
ユーザー flippergoflippergo
提出日時 2021-01-03 18:39:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 106,880 KB
最終ジャッジ日時 2024-04-21 13:46:25
合計ジャッジ時間 4,051 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
90,240 KB
testcase_01 AC 97 ms
90,112 KB
testcase_02 AC 100 ms
90,496 KB
testcase_03 AC 97 ms
90,240 KB
testcase_04 AC 97 ms
90,240 KB
testcase_05 AC 97 ms
90,368 KB
testcase_06 AC 96 ms
90,624 KB
testcase_07 AC 100 ms
90,368 KB
testcase_08 AC 103 ms
90,368 KB
testcase_09 AC 97 ms
90,752 KB
testcase_10 AC 98 ms
90,368 KB
testcase_11 AC 97 ms
90,368 KB
testcase_12 AC 96 ms
90,240 KB
testcase_13 AC 98 ms
90,368 KB
testcase_14 AC 101 ms
90,624 KB
testcase_15 AC 95 ms
90,496 KB
testcase_16 AC 99 ms
90,112 KB
testcase_17 AC 99 ms
90,624 KB
testcase_18 AC 98 ms
90,112 KB
testcase_19 AC 100 ms
90,496 KB
testcase_20 AC 99 ms
90,368 KB
testcase_21 AC 102 ms
90,752 KB
testcase_22 AC 147 ms
106,880 KB
testcase_23 AC 98 ms
90,752 KB
testcase_24 AC 101 ms
90,496 KB
testcase_25 AC 100 ms
90,368 KB
testcase_26 AC 100 ms
90,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = 998244353
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(2*10**6+1)]
for i in range(2,2*10**6+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(2*10**6+1)]
B[2*10**6] = pow(A[2*10**6],p-2)
for i in range(2*10**6-1,1,-1):
    B[i] = (B[i+1]*(i+1))%p
def f(n,k):
    if k>n or k<0:
        return 0
    if k==n or k==0:
        return 1
    return (A[n]*B[k]*B[n-k])%p
N,M = map(int,input().split())
if N>M or N==1:
    print(1)
else:
    m = M//N
    k = M%N
    cnt = 0
    for i in range(m+1):
        cnt = (cnt+f((m-i)*N+k+i,i))%p
    print(cnt)
0