← All problemsSign in

Cost of Solving

Description Chef has two integer variables sum=1 and cur=0. He can perform two operations with these variables $$\ O1: \text{ cur=sum, Where O1 has cost c1}$$ $$\ O2: \text{ sum=sum+cur, Where O2 has cost c2}$$ These two operations can be performed in any order and any number of times. For a given integer n , chef wants to find the minimal cost of all the operations so that, chef could get sum=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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start