Editorial
Since and each number does not exceed in absolute value, the sum of the given numbers can be up to approximately . To compute the result, use the long long type.
Algorithm realization
Read the input data until the end of the file. Sum up the given numbers.
res = 0; while(scanf("%lld",&n) == 1) res += n;
Print the result.
printf("%lld\n",res);
Java realization
import java.util.*; public class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); long sum = 0; while(con.hasNext()) { long val = con.nextLong(); sum += val; } System.out.println(sum); con.close(); } }
Python realization
import sys
Read the input data until the end of the file. Sum up the given numbers.
sum = 0 for line in sys.stdin: for var in line.split(): sum = sum + int(var)
Print the result.
print(sum)