← All problemsSign in

Chef and Number

Chef has provided you a number N and a value K, and he wants to reduce N to 1 by using following operations ( any number of times ) - N can be incremented by 1 - N can be decremented by 1 - N can be reduce to N/K ( if N is dividible by K ) Help chef to find out the minimum number of operations to be performed to reach 1 ? ###Input: - First line will contain $T$, number of testcase

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