-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution13.java
More file actions
24 lines (23 loc) · 857 Bytes
/
Copy pathSolution13.java
File metadata and controls
24 lines (23 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.*;
import java.math.BigInteger;
public class Solution13{
public static void main(String[] args) {
BufferedReader reader;
try{
reader = new BufferedReader(new FileReader("Input13.txt"));
BigInteger sum = new BigInteger("0");
//Utilizing log power rule for much faster computations, log_{b}(x^y) = y log_{b}(x).
String line = reader.readLine();
while(line != null){
//System.out.println(line);
BigInteger number = new BigInteger(line);
sum = sum.add(number);
//System.out.println(sum.toString());
line = reader.readLine();
}
System.out.println(sum.toString().substring(0, 10));
}catch(IOException e){
e.printStackTrace();
}
}
}