[Solution] Sum of Product 2 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 sum of over all the orderings of modulo .
Note that orderings here are defined in terms of indices, not elements; which is why every array of length has orderings. For example, the orderings of are:
- corresponding to indices
- corresponding to indices
- corresponding to indices
- corresponding to indices
- corresponding to indices
- corresponding to indices
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 le
- The second line contains space-separated integers denoting the array .
Output Format
For each test case, output the sum of over all the orderings of , modulo .
No comments:
Post a Comment