← All problemsSign in

Sub A Add B

CodeChefRating 817Open on judge ↗

Chef has a string of length $N$. The exact contents are irrelevant, only the length matters. Given $2$ parameters $A$ and $B$, Chef does the following repeatedly: - While the string is of length at least $A$, choose a substring of length $A$ from the string and replace it with a substring of length $B$. It is guaranteed that $B < A$, so this process will eventually terminate. Find the final le

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