QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#144659 | #3206. Acperience | someaccaccount | 100 ✓ | 645ms | 25836kb | Python3 | 414b | 2023-08-21 17:32:48 | 2023-08-21 17:32:50 |
Judging History
answer
from fractions import Fraction
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
s = 0
for i in arr:
s += abs(i)
ans = 0
for i in arr:
if i >= 0:
ans += (i * n - s) ** 2
else:
ans += (i * n + s) ** 2
ans = Fraction(ans, n ** 2)
print(f'{ans.numerator}/{ans.denominator}')
详细
Test #1:
score: 100
Accepted
time: 645ms
memory: 25836kb
input:
393 4 1 2 3 4 4 2 2 2 2 5 5 6 2 3 4 10 0 0 1 -1 -1 1 -1 1 -1 -1 10 -1 -1 -1 1 1 0 1 -1 -1 1 10 1 1 0 -1 0 1 0 1 -1 -1 10 0 0 0 1 -1 -1 1 1 1 1 10 -1 1 -1 -1 1 0 1 -1 -1 0 10 1 1 0 -1 1 -1 -1 -1 0 1 10 1 0 1 1 -1 -1 0 0 0 -1 10 -1 1 -1 -1 0 0 -1 1 1 1 10 0 -1 -1 0 -1 0 1 1 1 0 10 0 1 1 0 1 0 -1 1 1 1...
output:
5/1 0/1 10/1 8/5 9/10 21/10 21/10 8/5 8/5 12/5 8/5 12/5 21/10 12/5 5/2 21/10 21/10 21/10 8/5 21/10 21/10 5/2 12/5 12/5 12/5 5/2 12/5 12/5 8/5 12/5 5/2 21/10 21/10 21/10 21/10 12/5 9/10 8/5 9/10 12/5 21/10 8/5 12/5 21/10 9/10 5/2 5/2 12/5 21/10 21/10 21/10 21/10 21/10 12/5 5/2 12/5 8/5 8/5 21/10 21/1...
result:
ok 393 lines