Fun with Two
CodeChefOpen on judge ↗
You are given two integers $A$ and $B$, in which one of them is guaranteed to be equal to **2**. With $A$ and $B$, you are allowed to create any number $X$ which can be expressed as **$M*A + N*B$** for any non-negative integers $M$ and $N$. Find out the number of natural numbers which cannot be expressed as stated above. If there are infinite of them then print $-1$. ###Input: - First and only
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.
Sign in to chat with the tutor and save your progress.
Sign in to start