提交时间:2024-08-20 15:38:11

运行 ID: 169202

#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long ideas[n]; for (int i = 0; i < n; i++) { cin >> ideas[i]; } long long totalContribution = 0; for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { for (int k = j + 1; k < n; k++) { totalContribution += ideas[i] + ideas[j] + ideas[k]; } } } cout << totalContribution << endl; return 0; }