C++ 算法:计算混合复习获得的总能力值
#include
using namespace std;
int main() { int n; cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long totalAbility = 0;
for (int i = 0; i < n-1; i++) {
for (int j = i+1; j < n; j++) {
totalAbility += a[i] * a[j];
}
}
cout << totalAbility << endl;
return 0;
}
原文地址: http://www.cveoy.top/t/topic/qpmL 著作权归作者所有。请勿转载和采集!