結果

問題 No.1897 Sum of 2nd Max
ユーザー titiatitia
提出日時 2022-04-09 00:05:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 618 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 104,332 KB
最終ジャッジ日時 2023-08-19 02:35:02
合計ジャッジ時間 11,365 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
103,456 KB
testcase_01 AC 92 ms
103,464 KB
testcase_02 AC 92 ms
103,608 KB
testcase_03 AC 515 ms
104,212 KB
testcase_04 AC 525 ms
104,008 KB
testcase_05 AC 307 ms
104,160 KB
testcase_06 AC 307 ms
104,232 KB
testcase_07 AC 367 ms
104,168 KB
testcase_08 AC 322 ms
104,300 KB
testcase_09 AC 508 ms
104,332 KB
testcase_10 AC 481 ms
104,204 KB
testcase_11 AC 486 ms
104,276 KB
testcase_12 AC 496 ms
104,160 KB
testcase_13 AC 497 ms
104,052 KB
testcase_14 AC 194 ms
103,680 KB
testcase_15 AC 199 ms
103,912 KB
testcase_16 AC 256 ms
104,156 KB
testcase_17 AC 234 ms
103,992 KB
testcase_18 AC 256 ms
104,228 KB
testcase_19 AC 99 ms
103,284 KB
testcase_20 AC 94 ms
103,576 KB
testcase_21 AC 94 ms
103,492 KB
testcase_22 AC 97 ms
103,684 KB
testcase_23 AC 95 ms
103,684 KB
testcase_24 AC 98 ms
103,480 KB
testcase_25 AC 98 ms
103,516 KB
testcase_26 AC 96 ms
103,356 KB
testcase_27 AC 97 ms
103,524 KB
testcase_28 AC 94 ms
103,408 KB
testcase_29 AC 94 ms
103,492 KB
testcase_30 AC 508 ms
104,080 KB
testcase_31 AC 536 ms
104,224 KB
testcase_32 AC 434 ms
104,196 KB
testcase_33 AC 618 ms
104,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
mod=998244353

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0


ANS=0

for x in range(1,K+1):
    ANS+=x*N*(K-x)*(pow(x,N-1,mod)-pow(x-1,N-1,mod))%mod
    ANS+=x*(pow(x,N,mod)-pow(x-1,N,mod)-N*pow(x-1,N-1,mod))%mod

    ANS%=mod

print(ANS)
0