I. Innocence

Codeforces
IDCF10211I
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
David is a young child. He likes playing combinatorial games, for example, the Nim game. He is just an amateur but he is sophisticated with game theory. This time he has prepared a problem for you. Given integers N, L, R and K, you are asked to count in how many ways one can arrange an integer array of length N such that all its elements are ranged from L to R (inclusive) and the bitwise exclusive-OR of them equals to K. To avoid calculations of huge integers, print the number of ways in modulo (109 + 7). In addition, David would like you to answer with several integers K in order to ensure your solution is completely correct. The first line contains one integer T, indicating the number of test cases. The following lines describe all the test cases. For each test case: The first line contains four space-separated integers N, L, R and Q, indicating there are Q queries with the same N, L, R but different K. The second line contains Q space-separated integers, indicating several integers K. 1 ≤ T ≤ 1000, 1 ≤ N ≤ 109, 0 ≤ L ≤ R < 230, 1 ≤ Q ≤ 100, 0 ≤ K < 230. It is guaranteed that no more than 100 test cases do not satisfy 1 ≤ N ≤ 15, 0 ≤ L, R, K < 215. For each query, print the answer modulo (109 + 7) in one line. In the first sample, there are two ways to select one number 3 and one number 4 such that the exclusive-OR of them is 7. In the second sample, there are three ways to select one number 3 and two numbers 4 and one way to select three numbers 3 such that the exclusive-OR of them is 3. ## Input The first line contains one integer T, indicating the number of test cases.The following lines describe all the test cases. For each test case:The first line contains four space-separated integers N, L, R and Q, indicating there are Q queries with the same N, L, R but different K.The second line contains Q space-separated integers, indicating several integers K.1 ≤ T ≤ 1000, 1 ≤ N ≤ 109, 0 ≤ L ≤ R < 230, 1 ≤ Q ≤ 100, 0 ≤ K < 230.It is guaranteed that no more than 100 test cases do not satisfy 1 ≤ N ≤ 15, 0 ≤ L, R, K < 215. ## Output For each query, print the answer modulo (109 + 7) in one line. [samples] ## Note In the first sample, there are two ways to select one number 3 and one number 4 such that the exclusive-OR of them is 7.In the second sample, there are three ways to select one number 3 and two numbers 4 and one way to select three numbers 3 such that the exclusive-OR of them is 3.
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case: - Let $ N \in \mathbb{Z} $, $ L, R \in \mathbb{Z} $, $ Q \in \mathbb{Z} $ be parameters. - Let $ S = \{ x \in \mathbb{Z} \mid L \le x \le R \} $ be the set of allowed integers. - Let $ K_1, K_2, \dots, K_Q \in \mathbb{Z} $ be the query values. **Constraints** 1. $ 1 \le T \le 1000 $ 2. $ 1 \le N \le 10^9 $ 3. $ 0 \le L \le R < 2^{30} $ 4. $ 1 \le Q \le 100 $ 5. $ 0 \le K_j < 2^{30} $ for all $ j \in \{1, \dots, Q\} $ 6. At most 100 test cases have $ N \le 15 $ and $ L, R, K_j < 2^{15} $ **Objective** For each test case and each query $ K_j $, compute: $$ \left| \left\{ (x_1, \dots, x_N) \in S^N \mid x_1 \oplus x_2 \oplus \cdots \oplus x_N = K_j \right\} \right| \mod (10^9 + 7) $$
API Response (JSON)
{
  "problem": {
    "name": "I. Innocence",
    "description": {
      "content": "David is a young child. He likes playing combinatorial games, for example, the Nim game. He is just an amateur but he is sophisticated with game theory. This time he has prepared a problem for you. G",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10211I"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "David is a young child. He likes playing combinatorial games, for example, the Nim game. He is just an amateur but he is sophisticated with game theory. This time he has prepared a problem for you.\n\nG...",
      "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:  \n- Let $ N \\in \\mathbb{Z} $, $ L, R \\in \\mathbb{Z} $, $ Q \\in \\mathbb{Z} $ be parameters.  \n- Let $ S = \\...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments