Mood Balance
Time limit1sMemory limit1024 MB
Choose which minutes of an n-minute walk get negative thoughts so that the mood starts and ends at 0, using as few negative thoughts as possible.
- Level
Medium7 of 10
- Topics
- Math, Greedy, Implementation
- Solved
- No attempts yet
Statement
Autumn is a season of changing moods. Some people mourn the summer that is leaving, some are glad that winter is slowly arriving, and others simply stroll and enjoy the freshness and coolness of autumn.
When Kostya walks along an autumn avenue, deep thoughts about the meaning of life often come to him. Every minute a new thought comes to him, and Kostya chooses whether it is a negative thought or an ambiguous one. There are no positive thoughts.
If Kostya's current mood is and it is minute of the walk, then:
- a negative thought lowers his mood by , making it ;
- an ambiguous thought first changes his mood by , then doubles it, making it .
Kostya likes calm, so he wants his mood at the end of the walk to be , the same as before the walk started. He is also not fond of negative thoughts, so he wants to plan the walk with as few of them as possible.
Help Kostya plan his thoughts so that his mood is at the end of the walk, with as few negative thoughts as possible. His initial mood is , and the minutes of the walk are numbered from to .
Input
The only line contains one integer , the duration of the walk in minutes ().
Output
In the first line, print the minimum number of negative thoughts .
In the second line, print integers from to in increasing order, separated by spaces. These are the minutes in which Kostya should choose negative thoughts.