結果

問題 No.1554 array_and_me
ユーザー Kiri8128Kiri8128
提出日時 2021-06-18 23:03:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 95,964 KB
最終ジャッジ日時 2023-09-05 00:04:25
合計ジャッジ時間 9,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
78,996 KB
testcase_01 AC 120 ms
80,256 KB
testcase_02 AC 120 ms
80,268 KB
testcase_03 AC 125 ms
80,400 KB
testcase_04 AC 119 ms
80,272 KB
testcase_05 AC 119 ms
80,500 KB
testcase_06 AC 201 ms
95,748 KB
testcase_07 AC 199 ms
95,748 KB
testcase_08 AC 199 ms
95,656 KB
testcase_09 AC 200 ms
95,852 KB
testcase_10 AC 198 ms
95,836 KB
testcase_11 AC 194 ms
95,964 KB
testcase_12 AC 194 ms
95,752 KB
testcase_13 AC 194 ms
95,740 KB
testcase_14 AC 197 ms
95,844 KB
testcase_15 AC 195 ms
95,692 KB
testcase_16 WA -
testcase_17 AC 83 ms
78,976 KB
testcase_18 AC 82 ms
78,896 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 185 ms
82,344 KB
testcase_27 AC 184 ms
82,672 KB
testcase_28 AC 185 ms
82,276 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 182 ms
82,404 KB
testcase_32 WA -
testcase_33 AC 185 ms
82,280 KB
testcase_34 AC 184 ms
82,488 KB
testcase_35 WA -
testcase_36 AC 160 ms
82,044 KB
testcase_37 AC 160 ms
81,772 KB
testcase_38 AC 161 ms
82,264 KB
testcase_39 AC 164 ms
83,552 KB
testcase_40 AC 165 ms
83,408 KB
testcase_41 AC 125 ms
80,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353
nn = 202020

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0

T = int(input())
for _ in range(T):
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    su = sum(A)
    B = [K * a // su for a in A]
    su2 = sum(B)
    L = [(A[i] / (B[i] + 1), i) for i in range(N)]
    L.sort(key = lambda x: -x[0])
    for k in range(K - su2):
        i = L[k][1]
        B[i] += 1
    ans = fa[K]
    for i, b in enumerate(B):
        ans = ans * fainv[b] % P * pow(A[i], b, P) % P
    ans = ans * pow(su, (P - 2) * K, P) % P
    print(ans)
0