超级胶水
本题只需记住一点:不开longlong见祖宗
#include<iostream>
#define N 100010
using namespace std;
typedef long long LL;
int n;
int q[N];
int main()
{
scanf("%d",&n);
LL res = 0,sum = 0;
for(int i = 0;i < n;i ++)
{
scanf("%d",&q[i]);
if(i == 0) sum += q[i];
else if(i == 1)
{
res = (LL)q[i] * sum;
sum += q[i];
}
else
{
res += (LL)sum * q[i];
sum += q[i];
}
}
printf("%lld\n",res);
return 0;
}