結果

問題 No.1336 Union on Blackboard
ユーザー NatsubiSogan
提出日時 2021-01-15 21:32:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 392 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-11-26 13:24:21
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    a2 = []
    for i in a:
        if i == 0:
            continue
        a2.append(i)
    ans = 0
    n = len(a2)
    for i in range(n):
        for j in range(i + 1, n):
            ans += (a2[i] + a2[j]) + (a2[i] * a2[j])
            ans %= mod
    print(ans)
0