L. Lottery

Codeforces
IDCF10282L
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Little Rabbit walks into a shopping mall and comes across a lottery activity. There are $n$ boxes. Inside the $i$-th box, there are $x_i$ balls labeled with $2^(a_i)$. Little Rabbit can pick out any number (including zero) of balls from each box. The sum of numbers on the chosen balls is the score he gets. Whether Little Rabbit wins a prize in the lottery depends on the score. However, Little Rabbit doesn't care if he can win a prize. He is curious about how many different scores he is likely to get. Can you help him with it? Since the answer can be very large, please tell him the answer modulo $10^9 + 7$. The first line of the input contains an integer $T$ ($1 <= T <= 100$) — the number of test cases. In each test case, the first line contains an integer $n$ ($1 <= n <= 10^5$) — the number of boxes. The sum of $n$ will not exceed $10^5$. Then in the next $n$ lines, the $i$-th line contains two integers $a_i$ ($0 <= a_i <= 10^9$) and $x_i$ ($1 <= x_i <= 10^9$), which means there are $x_i$ balls numbered $2^(a_i)$ inside the $i$-th box. It's guaranteed that $a_1, a_2, \\dots, a_n$ are all distinct. For the $x$-th test case, if the answer modulo $10^9 + 7$ is $y$, output *$C a s e$ #$x$: $y$* in a single line. ## Input The first line of the input contains an integer $T$ ($1 <= T <= 100$) — the number of test cases.In each test case, the first line contains an integer $n$ ($1 <= n <= 10^5$) — the number of boxes. The sum of $n$ will not exceed $10^5$.Then in the next $n$ lines, the $i$-th line contains two integers $a_i$ ($0 <= a_i <= 10^9$) and $x_i$ ($1 <= x_i <= 10^9$), which means there are $x_i$ balls numbered $2^(a_i)$ inside the $i$-th box. It's guaranteed that $a_1, a_2, \\dots, a_n$ are all distinct. ## Output For the $x$-th test case, if the answer modulo $10^9 + 7$ is $y$, output *$C a s e$ #$x$: $y$* in a single line. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case, let $ n \in \mathbb{Z} $ be the number of boxes. For each box $ i \in \{1, \dots, n\} $, let $ a_i \in \mathbb{Z}_{\ge 0} $ and $ x_i \in \mathbb{Z}_{\ge 1} $, with all $ a_i $ distinct. Each box $ i $ contains $ x_i $ identical balls labeled $ 2^{a_i} $. **Constraints** 1. $ 1 \le T \le 100 $ 2. $ 1 \le n \le 10^5 $, and the sum of all $ n $ across test cases $ \le 10^5 $ 3. $ 0 \le a_i \le 10^9 $, $ 1 \le x_i \le 10^9 $, and all $ a_i $ are distinct **Objective** Compute the number of distinct possible scores obtainable by selecting any number of balls (from 0 to $ x_i $) from each box $ i $, where the score is the sum of the labels of selected balls. The score is: $$ S = \sum_{i=1}^n c_i \cdot 2^{a_i}, \quad \text{where } 0 \le c_i \le x_i $$ Return the count of distinct values of $ S $ modulo $ 10^9 + 7 $.
API Response (JSON)
{
  "problem": {
    "name": "L. Lottery",
    "description": {
      "content": "Little Rabbit walks into a shopping mall and comes across a lottery activity. There are $n$ boxes. Inside the $i$-th box, there are $x_i$ balls labeled with $2^(a_i)$. Little Rabbit can pick out any n",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10282L"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Little Rabbit walks into a shopping mall and comes across a lottery activity. There are $n$ boxes. Inside the $i$-th box, there are $x_i$ balls labeled with $2^(a_i)$. Little Rabbit can pick out any n...",
      "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, let $ n \\in \\mathbb{Z} $ be the number of boxes.  \nFor each box $ i \\in \\{1, \\dots, n\\} $, let $ a_i \\in \\...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments