#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long int d[10010];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lld",&d[i]);
sort(d,d+n);
long long int res=0;
long long int now=d[0];
for(int i=1;i<n;i++)
{
res+=d[i]*i-now;
now+=d[i];
}
printf("%lld\n",res*2);
return 0;
} poj 2231 Moo Volume
最新推荐文章于 2019-03-17 16:56:41 发布
本篇博客介绍了一个使用 C++ 实现的算法,该算法通过输入一系列整数,对其进行排序,并计算特定条件下的累积值。最终输出计算结果。

387

被折叠的 条评论
为什么被折叠?



