提交时间:2024-08-20 11:47:31

运行 ID: 168623

#include <iostream> using namespace std; int main() { int n; cin >> n; int values[1000]; for (int i = 0; i < n; ++i) cin >> values[i]; long long totalContribution = 0; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { for (int k = j + 1; k < n; ++k) totalContribution += values[i] + values[j] + values[k]; } } cout << totalContribution << endl; return 0; }