BC106 - Editorial

array
easy
editorial
sum

#1

#PROBLEM LINK:

Practice
Contest

Author: Ayush Nagal

#DIFFICULTY:
EASY

#PREREQUISITES:
Math

#PROBLEM:
Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.

#EXPLANATION:
The only catch is that \text{the integers may be quite large}. For that, we need to use the long long int datatype because the range of int datatype will get exceeded in the test cases.

long long int temp,s;
for(int i=0;i<t;i++)
{
    cin>>temp;
    s+=temp;
}
cout<<s;

The final sum of the elements of the array will be stored in s.

#AUTHOR’S SOLUTION:
Author’s solution can be found here.