結果

問題 No.1510 Simple Integral
ユーザー lam6er
提出日時 2025-04-16 00:55:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 591 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 61,544 KB
最終ジャッジ日時 2025-04-16 00:56:59
合計ジャッジ時間 3,479 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n = int(input())
a = list(map(int, input().split()))

result = 0
for k in range(n):
    ak = a[k]
    ak_sq = (ak * ak) % MOD
    product = 1
    for i in range(n):
        if i == k:
            continue
        ai_sq = (a[i] * a[i]) % MOD
        term = (ai_sq - ak_sq) % MOD
        product = (product * term) % MOD
    # Compute inverse of product
    inv_product = pow(product, MOD - 2, MOD)
    # Compute inverse of ak
    inv_ak = pow(ak, MOD - 2, MOD)
    # Add term to result
    term = (inv_ak * inv_product) % MOD
    result = (result + term) % MOD

print(result)
0