Laws
시간 제한2초메모리 제한256 MB
x개의 동전에서 시작해 하루가 지나면 1개가 늘고, 2나 3으로 나누어떨어질 때마다 절반 또는 3분의 1로 줄일 수 있다. 정확히 1개를 남기는 최소 일수와 그 과정을 출력한다.
문제
There are two inhabitants in the Faraway Kingdom: Alyonushka the Peasant and Ivanushka the King. Alyonushka works on a farm, and Ivanushka makes laws.
Alyonushka has coins. Each day, Alyonushka gets one more coin from the treasury for her work. The amount of coins in the treasury can be considered infinite.
If the number of Alyonushka's coins divides evenly by two, Ivanushka can make another peasant law, and Alyonushka will be allowed to keep only half of her coins: the other half immediately goes to the treasury. If the number of Alyonushka's coins divides evenly by three, Ivanushka can make another farm law, and Alyonushka will be allowed to keep only one third of her coins: the other two thirds immediately go to the treasury. Ivanushka can make new laws at any moment, in any order, and do it any number of times.
Today Ivanushka got angry with Alyonushka. Now he wishes Alyonushka to have only one coin left. What is the minimum possible number of days required to achieve that?
입력
The first line of input contains an integer : the initial number of Alyonushka's coins ().
출력
On the first line, print : the minimum possible number of days required for Ivanushka to leave Alyonushka with only one coin. On the second line, print a sequence of integers: any possible sequence of events which takes days and transforms coins into . The sequence must start with and end with . Every two consecutive numbers and in the sequence must satisfy either (a day has passed), (a new peasant law has been made), or (a new farm law has been made).