链接:https://ac.nowcoder.com/acm/contest/55407/E
来源:牛客网
输入描述:
#include <iostream>
using namespace std;
const int N=2e5+10;
typedef long long ll;
ll sum[N],a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
sum[i]=sum[i-1]+a[i];
}
ll s=0;
for(int i=0;i<n;i++){
s=s+(sum[n-1]-sum[i])*a[i];
}
cout<<s;
return 0;
}
2023哈理工蓝桥杯模拟练习赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)
标签:前缀,int,sum,cin,a1,a2,ll From: https://www.cnblogs.com/saulgoodman1/p/17297445.html