← All problemsSign in

Modular Inverse

Given an integer dividend $p$ and divisor $q$, find the smallest integer $n$ such that $(p*n)$ $\%$ $q$ leaves a remainder of $1$ ###Input - There will be a single line of input, containing $p$ and $q$ separated by a space. ###Output - Output $n$. If no such number $n$ exists, output the word *None*. ###Constraints - For half the points, $2 \leq p < q \leq 2^{31} - 1$ - For the other

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start