032. Prison Break

Codeforces
IDCF10269032
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Unfortunately, you have been sent to prison because you solved too many problems at CodeQuest 2021. Now, you're trying to break out. Your cell has a combination lock with $n$ dials. You're planning to try all of the possible combinations of the lock, and you want to know how many possible combinations the lock has. The first line of input contains a positive integer $n$: the number of dials on the lock. The next $n$ lines each contain two space-separated integers: the lower and upper limits of each lock dial. For example, if the lower and upper limits were $3$ and $7$, respectively, then the lock dial could turn to 3, 4, 5, 6, or 7. Output a single integer $c$: the total number of possible lock combinations. ## Input The first line of input contains a positive integer $n$: the number of dials on the lock. The next $n$ lines each contain two space-separated integers: the lower and upper limits of each lock dial. For example, if the lower and upper limits were $3$ and $7$, respectively, then the lock dial could turn to 3, 4, 5, 6, or 7. ## Output Output a single integer $c$: the total number of possible lock combinations. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of dials. For each dial $ i \in \{1, \dots, n\} $, let $ [l_i, u_i] \subseteq \mathbb{Z} $ denote the range of possible values, where $ l_i $ and $ u_i $ are the lower and upper limits, respectively. **Constraints** For each $ i \in \{1, \dots, n\} $: $ l_i \leq u_i $ **Objective** Compute the total number of combinations: $$ c = \prod_{i=1}^{n} (u_i - l_i + 1) $$
API Response (JSON)
{
  "problem": {
    "name": "032. Prison Break",
    "description": {
      "content": "Unfortunately, you have been sent to prison because you solved too many problems at CodeQuest 2021. Now, you're trying to break out. Your cell has a combination lock with $n$ dials. You're planning to",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269032"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Unfortunately, you have been sent to prison because you solved too many problems at CodeQuest 2021. Now, you're trying to break out. Your cell has a combination lock with $n$ dials. You're planning to...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of dials.  \nFor each dial $ i \\in \\{1, \\dots, n\\} $, let $ [l_i, u_i] \\subseteq \\mathbb{Z} $ denote the range of possible values, where $ l_i...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments