Skip to content

Commit 56567dc

Browse files
authored
Create aVeryBigSum.java
1 parent 3b4ef28 commit 56567dc

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Java/Algorithms/aVeryBigSum.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.io.*;
2+
import java.math.*;
3+
import java.security.*;
4+
import java.text.*;
5+
import java.util.*;
6+
import java.util.concurrent.*;
7+
import java.util.regex.*;
8+
9+
public class Solution {
10+
11+
// Complete the aVeryBigSum function below.
12+
static long aVeryBigSum(long[] ar) {
13+
long sum =0;
14+
for (int l=0; l<ar.length; l++) {
15+
sum += ar[l];
16+
}
17+
return sum;
18+
}
19+
20+
private static final Scanner scanner = new Scanner(System.in);
21+
22+
public static void main(String[] args) throws IOException {
23+
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
24+
25+
int arCount = scanner.nextInt();
26+
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
27+
28+
long[] ar = new long[arCount];
29+
30+
String[] arItems = scanner.nextLine().split(" ");
31+
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
32+
33+
for (int i = 0; i < arCount; i++) {
34+
long arItem = Long.parseLong(arItems[i]);
35+
ar[i] = arItem;
36+
}
37+
38+
long result = aVeryBigSum(ar);
39+
40+
bufferedWriter.write(String.valueOf(result));
41+
bufferedWriter.newLine();
42+
43+
bufferedWriter.close();
44+
45+
scanner.close();
46+
}
47+
}

0 commit comments

Comments
 (0)