You are viewing a single comment's thread. Return to all comments →
ArrayList<BigInteger> arr = new ArrayList<>(); Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for (int i = 0; i < N; i++) { BigInteger line = sc.nextBigInteger(); arr.add(line); } BigInteger sum = new BigInteger("0"); for (int i = 0; i < arr.size(); i++) { BigInteger get = arr.get(i); sum = sum.add(get); } String sSum = String.valueOf(sum); String result = ""; for (int i = 0; i < 10; i++) { result += sSum.charAt(i); } System.out.println(result);
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #13: Large sum
You are viewing a single comment's thread. Return to all comments →
java