Door Door Door
Time limit1sMemory limit256 MB
Assign 0 or 1 to each door so no two consecutive doors match and all multiples of 2 agree and all multiples of 3 agree, given door 1.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Number theory, Brute force
- Solved
- No attempts yet
Problem
Yushin is trapped in a room where he must pass through several doors to get out. Jaehyun, who trapped him, set up a system with unusual rules so that Yushin must open the doors in order, following the rules, and thereby cannot escape.
- Rule 1: There are two ways to open a door. You can push it open or pull it open.
- Rule 2: You cannot open two consecutive doors the same way.
- Rule 3: The doors at multiples of 2 (2nd, 4th, 6th, ...) must all be opened the same way. For example, if the 2nd door is opened by pushing, the 4th door must also be opened by pushing.
- Rule 4: The doors at multiples of 3 (3rd, 6th, 9th, ...) must all be opened the same way. For example, if the 3rd door is opened by pushing, the 6th door must also be opened by pushing.
Even though Yushin knows all four rules above, he cannot escape. Write a program that helps Yushin escape the room.
Input
The first line gives the total number of doors .
The second line gives the way Yushin opened the first door. Pushing is written as 0 and pulling is written as 1.
Output
Print the way to open each door from the second door onward, one per line. If escape is impossible, print "Love is open door".