Balloon Popping
InterviewTime limit0.5sMemory limit1024 MB
Given N balloons popped by A, B, and C at multiples of x, y, and z (ties go to A, then B, then C), print who pops the last balloon.
- Level
Medium4 of 10
- Topics
- Math, Binary search
- Solved
- No attempts yet
Problem
A, B, and C play a game where they pop balloons.
- A pops one balloon every minutes. A pops balloons at minutes after the game starts.
- B pops one balloon every minutes. B pops balloons at minutes after the game starts.
- C pops one balloon every minutes. C pops balloons at minutes after the game starts.
- If two or more people pop a balloon at the same time, they pop in the order A, B, C.
The person who pops the last balloon wins. Print the winner among A, B, and C.
Input
The first line contains the number of balloons and the times , , it takes to pop a balloon. (, and , , , are all integers.)
Output
Print the winner of the game. Print A win if A wins, B win if B wins, or C win if C wins.