QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#144659#3206. Acperiencesomeaccaccount100 ✓645ms25836kbPython3414b2023-08-21 17:32:482023-08-21 17:32:50

Judging History

你现在查看的是最新测评结果

  • [2023-08-21 17:32:50]
  • 评测
  • 测评结果:100
  • 用时:645ms
  • 内存:25836kb
  • [2023-08-21 17:32:48]
  • 提交

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