Skip to content

Instantly share code, notes, and snippets.

@ClearNB
Last active January 7, 2019 07:44
Show Gist options
  • Save ClearNB/f2438b803dbad53ca1634e6055a415d8 to your computer and use it in GitHub Desktop.
Save ClearNB/f2438b803dbad53ca1634e6055a415d8 to your computer and use it in GitHub Desktop.
Large sum (Java 8 ver) Sample by ClearNB
import java.math.BigInteger;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
BigInteger bi = new BigInteger("0");
try (Scanner sc = new Scanner(System.in)) {
int N = sc.nextInt();
for(int i = 0; i < N; i++) {
BigInteger nl = sc.nextBigInteger();
bi = bi.add(nl);
}
System.out.println(bi.toString().substring(0, 10));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment