A Very Big Sum

  • + 0 comments

    You can solve this issue with ease. The pitfall with accumulate is that it assumes the return type to be the type of the initial value of the sum ( the third argument passed to accumulate ) so , this would work :

    long long int total = accumulate(arr.begin(),arr.end(), long long 0);
    or
    long long int total = accumulate(arr.begin(),arr.end(), 0LL );