Substraction
CodeChefOpen on judge ↗
Little chef is learning how to decrease a number by one, but he does it wrong with a number consisting of two or more digits. Chef subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, he decreases the number by one. if the last digit of the number is zero, he divides the number by 10 (i.e. removes the last digit). You are given an integer number n
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