Max Minus Min
Consider an infinite sequence $X_i$ of nonnegative integers, in which $X_1 = A$, $X_2 = B$, $X_3 = C$, and for $i\ge 4$, $$X_i = \max(X_{i-3}, X_{i-2}, X_{i-1}) - \min(X_{i-3}, X_{i-2}, X_{i-1})$$ Find the $K$-th term of this sequence. ### Input - The first line of input contains a single integer $T$, denoting the number of test cases. The description of $T$ test cases follows. - The only line
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