A Very Big Sum

  • + 5 comments

    Because the type of the accumulator that will be used to determine the sum is based on the type of the third input argument. The literal 0 is not being interpreted as long long int. If you cast the initial value to accumulate appropriately, you get the right answer.

    accumulate(arr.begin(),arr.end(),static_cast<long long int>(0))