Onion Experiment
Time limit1sMemory limit1024 MB
Simulate N days of two onions: praise adds A, criticism adds B, roles swap when the criticized onion is longer, and a tie cuts it by 1. Print both lengths.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Problem
Younghyun wants to teach his students a lesson with an 'onion experiment'. The onion experiment compares how fast onions grow when they receive praise versus criticism.
He expected the 'praised onion' to grow faster than the 'criticized onion'. However, the 'criticized onion' grew faster after being moved by the students' diss rap.
Younghyun reluctantly decided to manipulate the experiment and carried it out as follows.
The first length of both onions is . Give one onion the role of 'praised onion' and the other the role of 'criticized onion'.
- Every day, students praise the 'praised onion' and criticize the 'criticized onion'. Praising an onion makes it grow by , and criticizing an onion makes it grow by . (Here, )
- Check the onions. If the 'criticized onion' is longer than the 'praised onion', swap their roles.
- If the two onions have the same length, cut the 'criticized onion' by .
Each day, steps 1, 2, and 3 are carried out in this order during the experiment.
Print the result of the experiment after days.
Input
The first line contains the number of days the experiment runs, the growth from praising an onion, and the growth from criticizing an onion. (, and are all integers.)
Output
When the experiment ends, print the length of the 'praised onion' and the length of the 'criticized onion', in that order.