#B3696. Lucky Number Modulo Calculation
Lucky Number Modulo Calculation
Lucky Number Modulo Calculation
An integer x represents E's lucky number in 2022, which can be either positive or negative. You are required to compute the remainder r when x is divided by 2023 such that:
\( x = k \times 2023 + r \) where \(0 \le r < 2023\).
Note: In many programming languages, using the modulo operator (\(\%\)) on negative numbers yields a negative result. To ensure the remainder is non-negative, if the computed result is negative, add 2023 to it.
For example:
- \(2022 \bmod 2023 = 2022\)
- \(2025 \bmod 2023 = 2\)
- \(-2 \bmod 2023 = 2021\)
- \(-2026 \bmod 2023 = 2020\)
inputFormat
The input consists of a single integer x (which may be negative) representing the lucky number.
outputFormat
Output a single integer r, the remainder when x is divided by 2023, satisfying \(0 \le r < 2023\).
sample
2022
2022