QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#144656 | #3206. Acperience | someaccaccount | 0 | 0ms | 0kb | Python3 | 397b | 2023-08-21 17:30:57 | 2023-08-21 17:30:57 |
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)
s = Fraction(s, n)
ans = 0
for i in arr:
if i >= 0:
ans += (i - s) ** 2
else:
ans += (i + s) ** 2
print(f'{ans.numerator}/{ans.denominator}')
详细
Test #1:
score: 0
Time Limit Exceeded
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...