fork download
  1. #include <iostream>
  2. #include <numeric>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. const vector<int> box = { 2, 3, 4, 6 };
  9.  
  10. cout << accumulate(next(cbegin(box)), cend(box), box.front() * (box.size() - 1), [i = box.size()](const auto lhs, const auto rhs) mutable { return lhs + rhs * --i; }) << endl;
  11. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
29