← All problemsSign in

To Divide or Not To Divide

CodeChefRating 1224Open on judge ↗

Alice likes all the numbers which are divisible by $A$. Bob does **not** like the numbers which are divisible by $B$ and likes all the remaining numbers. Determine the smallest number **greater than or equal to** $N$ which is liked by both Alice and Bob. Output $-1$ if no such number exists. ### Input - The first line contains a single integer $T$ — the number of test cases. Then the test cases f

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