 # DARLIG Editorial

Setter: Rudro Debnath
Tester: Felipe Mota, Abhinav Sharma
Editorialist: Pratiyush Mishra

994

None

# PROBLEM:

Tonmoy has a special torch. The torch has 4 levels numbered 1 to 4 and 2 states (\texttt{On} and \texttt{Off}). Levels 1, 2, and 3 correspond to the \texttt{On} state while level 4 corresponds to the \texttt{Off} state.

The levels of the torch can be changed as:

• Level 1 changes to level 2.
• Level 2 changes to level 3.
• Level 3 changes to level 4.
• Level 4 changes to level 1.

Given the initial state as K and the number of changes made in the levels as N, find the final state of the torch. If the final state cannot be determined, print \texttt{Ambiguous} instead.

# EXPLANATION:

Lets take this case by case for K:

• K = 0: This corresponds to state 4. Here if the number of changes, i.e N is a multiple of 4 then that means that it would again reach the state of 4 and so the final state would be off else if it is not a multiple of 4, then the final state would be among 1, 2, 3 which would imply the on state.
• K = 1: This corresponds to any one of the state among 1,2,3. Here again if the number of changes, i.e N is a multiple of 4, it would mean that the final state would be the same as initial state. Thus it would remain on as it was initially. Else if N is not a multiple of 4, then we cannot comment on the final state and so it would be Ambiguous.

# TIME COMPLEXITY:

O(1) for each test case.

2 Likes