[Solution] Sum of Product 1 CodeChef Solution 2022
Problem
For an array of length , let denote the sum of the product of all the subarrays of . Formally,
For example, let , then there are possible subarrays:
- Subarray has product
- Subarray has product
- Subarray has product
- Subarray has product
- Subarray has product
- Subarray has product
So .
Given a binary array , determine the value of .
👇👇👇👇👇
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer denoting the length of the array.
- The second line contains space-separated integers denoting the array .
Output Format
For each test case, output on a new line the value of .
Explanation:
Test case : Explained in the statement.
Test case : There is only subarray and it has product .
Test case : All the subarrays have product .
No comments:
Post a Comment