Subarray Last
Practice
3.6 (5 votes)
Math
Basic math
Observation
C++
Problem
56% Success 228 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array \(X\) of \(N\) integers. We define the \(value\) of a subarray as the last element of the subarray. Find the sum of the \(value\) of all possible subarrays. A subarray is any contiguous part of the array.
Input Format:
- The first line contains an integer \(T\), which denotes the number of test cases.
- The first line of each test case contains one integers \(N\) denoting the number of elements in the array \(X\).
- The second line of each test case contains \(N\) integers denoting the elements of \(X\).
Output format:
For each test case, print the sum of the \(value\) of all subarrays of the given array \(X\).
Constraints:
\(1 <= T <= 10\)
\(1 <= N <= 10^5\)
\(1 <= X_i <= 10^5\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
2 votes
Tags:
Maths
Points:20
4 votes
Tags:
Easy
Points:20
Tags:
Binary SearchMath BasicMath
Editorial