# PROBLEM LINK:

**Setter:** iceknight1093

**Testers:** gamegame

**Editorialist:** hrishik85

# DIFFICULTY:

679

# PREREQUISITES:

None

# PROBLEM:

Chef is playing a videogame, and is getting close to the end. He decides to finish the rest of the game in a single session.

There are X levels remaining in the game, and each level takes Chef Y minutes to complete. To protect against eye strain, Chef also decides that every time he completes 3 levels, he will take a Z minute break from playing. Note that there is no need to take this break if the game has been completed.

How much time (in minutes) will it take Chef to complete the game?

# EXPLANATION:

The total time to complete **only** the levels = X \times Y

The number of gaps if X is not divisible by 3 are Gaps = X \div 3 (rounded down to the closest integer)

The number of gaps if X is divisible by 3 are Gaps = (X \div 3) - 1

Hence - total time to complete the game = X \times Y + Gaps \times Z

# TIME COMPLEXITY:

Time complexity is O(1).

# SOLUTION:

## Editorialist's Solution

```
t=int(input())
for _ in range(t):
x,y,z=map(int,input().split())
gap=0
if x%3==0:
gap = (x//3)-1
else:
gap= (x//3)
print(x*y+gap*z)
```