A Very Big Sum

Sort by

recency

|

2015 Discussions

|

  • + 0 comments

    Java Short Solution

    public static long aVeryBigSum(List ar) { // Write your code here long sum=0; for(long i:(ar)) sum+=i; return sum; }

  • + 1 comment

    I have spent so much time to transform between str and int and do the manual computation digit by digit to ensure the storage. And then it turns out we don't need to consider the storage at all? JUST SUM???

  • + 0 comments

    For Python3 Platform

    I wrote the code from scratch just to get more practice

    def aVeryBigSum(ar):
        return sum(ar)
    
    n = int(input())
    ar = list(map(int, input().split()))
    
    res = aVeryBigSum(ar)
    
    print(res)
    
  • + 0 comments

    Only the return satement is needed to complete the code in Pypy3

    import os
    
    def aVeryBigSum(ar):
      
        return (sum(ar))
    
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        ar_count = int(input().strip())
    
        ar = list(map(int, input().rstrip().split()))
    
        result = aVeryBigSum(ar)
    
        fptr.write(str(result) + '\n')
    
        fptr.close()
    
  • + 0 comments
    #include <stdio.h>
    
    long a_very_big_sum(int count, long a[]);
    
    long fill_vector(long a[], int count);
    
    long a_very_big_sum(int count, long a[]) {
        
         long sum = 0;
         
        for (int i = 0; i < count; i++) {
            sum += a[i];
        }
        
        return sum;
    }
    
    long fill_vector(long a[], int count) {
        
        for (int i = 0; i < count; i++) {
            scanf("%ld", &a[i]);
        }
        
        return a_very_big_sum(count, a);
    }
    
    
    int main() {
        
        int count = 0;
        
        scanf("%d", &count);
        
        long a[count];
        
        
        long result = fill_vector(a,count);
        
        printf("%ld", result);
        
        return 0;
    }