P10090 [ROIR 2022] New Year in Kindergarten (Day 2)
Background
Translated and simplified from [ROIR 2022 D2T1](https://neerc.ifmo.ru/school/archive/2021-2022/ru-olymp-regional-2022-day2.pdf).
Description
Given three integers $n, a, b$, find how many pairs $(x, y)$ satisfy $0 \le x \le a$, $0 \le y \le b$, $x + y$ is not $0$, and $x + y$ is divisible by $n$.
Input Format
This problem has multiple test cases. The first line contains an integer $t$, representing the number of test cases.
The next $t$ lines each contain one test case: $n, a, b$, separated by spaces.
Output Format
For each test case, output one number per line, which is the number of valid $(x, y)$ pairs.
Explanation/Hint
This problem uses bundled testdata.
| Subtask | Points | Special Properties |
| :----------: | :----------: | :----------: |
| $1$ | $10$ | $t = 1$ and $a, b \le 1000$ |
| $2$ | $10$ | $t \le 1000$ and $a = 0$ |
| $3$ | $15$ | $t \le 1000$ and $a, b < n \le 1000$ |
| $4$ | $10$ | $t \le 1000$ and $a, b \le 1000$ |
| $5$ | $15$ | $t = 1$ and $n \le 1000$ |
| $6$ | $10$ | $t \le 1000$ and $n \le 1000$ |
| $7$ | $30$ | No special properties |
For $100\%$ of the testdata, $1 \le t \le 10^5$, $4 \le n \le 10^9$, and $0 \le a, b \le 10^9$.
Translated by ChatGPT 5