J. The Hell Boy

Codeforces
IDCF10153J
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Since the problem set was hard, here is an easy task for you to solve. You are given an array a consisting of n integers, and your task is to calculate the summation of the multiplication of all subsets of array a. (See the note for more clarifications) A subset of an array a is defined as a set of elements that can be obtained by deleting zero or more elements from the original array a. The first line contains an integer T, where T is the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 105), where n is the size of array a. The second line of each test case contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106), giving the array a. For each test case, print a single line containing the summation of the multiplication of all subsets of array a. Since this number may be too large, print the answer modulo 109 + 7. As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use _scanf/printf_ instead of _cin/cout_ in C++, prefer to use _BufferedReader/PrintWriter_ instead of _Scanner/System.out_ in Java. In the first test case, the array a has 6 subsets, and the answer is calculated as follow: ## Input The first line contains an integer T, where T is the number of test cases.The first line of each test case contains an integer n (1 ≤ n ≤ 105), where n is the size of array a.The second line of each test case contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106), giving the array a. ## Output For each test case, print a single line containing the summation of the multiplication of all subsets of array a. Since this number may be too large, print the answer modulo 109 + 7. [samples] ## Note As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use _scanf/printf_ instead of _cin/cout_ in C++, prefer to use _BufferedReader/PrintWriter_ instead of _Scanner/System.out_ in Java.In the first test case, the array a has 6 subsets, and the answer is calculated as follow: (1) + (2) + (3) + (1 × 2) + (1 × 3) + (2 × 3) + (1 × 2 × 3) = 23.
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $: - Let $ n_k \in \mathbb{Z} $ denote the size of the array. - Let $ A_k = (a_{k,1}, a_{k,2}, \dots, a_{k,n_k}) $ be a sequence of positive integers. **Constraints** 1. $ 1 \le T \le 10^5 $ 2. For each $ k \in \{1, \dots, T\} $: - $ 1 \le n_k \le 10^5 $ - $ 1 \le a_{k,i} \le 10^6 $ for all $ i \in \{1, \dots, n_k\} $ **Objective** For each test case $ k $, compute: $$ S_k = \sum_{\substack{S \subseteq A_k \\ S \neq \emptyset}} \prod_{x \in S} x \mod (10^9 + 7) $$ That is, the sum of the products of all non-empty subsets of $ A_k $.
API Response (JSON)
{
  "problem": {
    "name": "J. The Hell Boy",
    "description": {
      "content": "Since the problem set was hard, here is an easy task for you to solve. You are given an array a consisting of n integers, and your task is to calculate the summation of the multiplication of all subs",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10153J"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Since the problem set was hard, here is an easy task for you to solve.\n\nYou are given an array a consisting of n integers, and your task is to calculate the summation of the multiplication of all subs...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ n_k \\in \\mathbb{Z} $ denote the size of the array.  \n- Let $ A_k = (a_...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments