牛的距离
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
在一条数轴上有N(N$\leq$10000)头牛在不同的位置上,每头牛都计算到其它各头牛的距离。求这n*(n-1)个距离的总和。
Input Format
第一行:N 后面N行,每行一个整数,表示一头牛所在位置。
Output Format
一个整数。
Sample
input
5
1
5
3
2
4
output
40
说明:
(1+2+3+4)+(4+3+2+1)
+(2+1+1+2)+(1+1+2+3)
+(3+2+1+1) = 40
Hint
时间限制:
空间限制:
20200810数组基本练习
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 12
- Start at
- 2020-8-10 9:48
- End at
- 2020-8-11 9:48
- Duration
- 24 hour(s)
- Host
- Partic.
- 43