Friday, July 28, 2017

Hackerrank: A Very Big Sum

Sample Input
5
1000000001 1000000002 1000000003 1000000004 1000000005
Output
5000000015
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    static long aVeryBigSum(int n, long[] ar) {
        // Complete this function
        long result = 0;
        
        for (int i = 0;i
        {
            result = result + ar[i];
        }
        
        return result;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] ar = new long[n];
        for(int ar_i = 0; ar_i < n; ar_i++){
            ar[ar_i] = in.nextLong();
        }
        long result = aVeryBigSum(n, ar);
        System.out.println(result);
    }
}

No comments:

Post a Comment

KOMENTAR ANDA, MOTIVASI BAGI SAYA...!