C. Sum of Log

Codeforces
IDCF10290C
Time1000ms
Memory1024MB
Difficulty
English · Original
Formal · Original
Given two non-negative integers $X$ and $Y$, determine the value of $$ \sum_{i=0}^{X}\sum_{j=[i=0]}^{Y}[i\&j=0]\lfloor\log_2(i+j)+1\rfloor $$ modulo $10^9 + 7$ where The first line contains one integer $T thin (1 <= T <= 10^5)$ denoting the number of test cases. Each of the following $T$ lines contains two integers $X, Y thin (0 <= X, Y <= 10^9)$ indicating a test case. For each test case, print one line containing one integer, the answer to the test case. For the first test case: So the answer is $1 times 2 + 2 times 6 = 14$. ## Input The first line contains one integer $T thin (1 <= T <= 10^5)$ denoting the number of test cases.Each of the following $T$ lines contains two integers $X, Y thin (0 <= X, Y <= 10^9)$ indicating a test case. ## Output For each test case, print one line containing one integer, the answer to the test case. [samples] ## Note For the first test case: Two $(i, j)$ pairs increase the sum by 1: $(0, 1), (1, 0)$ Six $(i, j)$ pairs increase the sum by 2: $(0, 2), (0, 3), (1, 2), (2, 0), (2, 1), (3, 0)$ So the answer is $1 times 2 + 2 times 6 = 14$.
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $, let $ X_k, Y_k \in \mathbb{Z}_{\geq 0} $ be given integers. **Constraints** 1. $ 1 \leq T \leq 10^5 $ 2. $ 0 \leq X_k, Y_k \leq 10^9 $ for all $ k \in \{1, \dots, T\} $ **Objective** For each test case $ k $, compute: $$ S_k = \left( \sum_{i=0}^{X_k} \sum_{j=[i=0]}^{Y_k} \mathbf{1}_{i \& j = 0} \cdot \left\lfloor \log_2(i + j) + 1 \right\rfloor \right) \mod (10^9 + 7) $$ where $ [i=0] $ is the Iverson bracket: $ [i=0] = 1 $ if $ i = 0 $, else $ 0 $, and $ \mathbf{1}_{i \& j = 0} $ is the indicator that the bitwise AND of $ i $ and $ j $ is zero.
API Response (JSON)
{
  "problem": {
    "name": "C. Sum of Log",
    "description": {
      "content": "Given two non-negative integers $X$ and $Y$, determine the value of $$ \\sum_{i=0}^{X}\\sum_{j=[i=0]}^{Y}[i\\&j=0]\\lfloor\\log_2(i+j)+1\\rfloor $$ modulo $10^9 + 7$ where  The first line contains one inte",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 1048576
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10290C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given two non-negative integers $X$ and $Y$, determine the value of $$ \\sum_{i=0}^{X}\\sum_{j=[i=0]}^{Y}[i\\&j=0]\\lfloor\\log_2(i+j)+1\\rfloor $$ modulo $10^9 + 7$ where \n\nThe first line contains one inte...",
      "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\\} $, let $ X_k, Y_k \\in \\mathbb{Z}_{\\geq 0} $ be given integers.\n\n**Constraints**  \n1...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments