結果

問題 No.1554 array_and_me
ユーザー mkawa2mkawa2
提出日時 2023-11-07 14:00:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,525 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 123,868 KB
最終ジャッジ日時 2023-11-07 14:01:12
合計ジャッジ時間 27,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
100,816 KB
testcase_01 AC 413 ms
101,828 KB
testcase_02 AC 412 ms
102,156 KB
testcase_03 AC 437 ms
102,204 KB
testcase_04 AC 409 ms
102,152 KB
testcase_05 AC 415 ms
102,152 KB
testcase_06 WA -
testcase_07 AC 855 ms
123,812 KB
testcase_08 AC 803 ms
123,816 KB
testcase_09 AC 848 ms
123,816 KB
testcase_10 AC 827 ms
123,816 KB
testcase_11 AC 324 ms
123,816 KB
testcase_12 AC 326 ms
123,820 KB
testcase_13 AC 347 ms
123,812 KB
testcase_14 AC 322 ms
123,816 KB
testcase_15 AC 325 ms
123,816 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 660 ms
111,580 KB
testcase_37 AC 685 ms
111,196 KB
testcase_38 AC 651 ms
110,916 KB
testcase_39 AC 685 ms
111,512 KB
testcase_40 AC 674 ms
110,872 KB
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

from heapq import *
from fractions import Fraction

def inv_arr(n):
    if n < 1: return []
    res = [-1, 1]
    for i in range(2, n+1):
        res.append(res[md%i]*(md-md//i)%md)
    return res

inv=inv_arr(100005)

n_max = 100005
fac = [1]
for i in range(1, n_max+1): fac.append(fac[-1]*i%md)
ifac = [1]*(n_max+1)
ifac[n_max] = pow(fac[n_max], md-2, md)
for i in range(n_max-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%md

def solve():
    n,k=LI()
    aa=LI()
    ans=fac[k]*pow(sum(aa),(md-2)*k,md)%md
    hp=[Fraction(1,a) for a in aa]
    heapify(hp)
    for _ in range(k):
        f=heappop(hp)
        x,a=f.numerator,f.denominator
        ans*=a*inv[x]%md
        ans%=md
        heappush(hp,Fraction(x+1,a))
    print(ans)

for _ in range(II()):solve()
0