ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

USU Open Personal Contest 2010

About     Problems     Submit solution     Judge status     Standings
Contest is over

F. Bald Spot Revisited 2

Time limit: 1.0 second
Memory limit: 64 MB
Travis wanted to relax and took a walk round the town's pubs. Sitting at the first pubs, he realized that walking round the pubs one after another was not interesting at all, so he numbered all the pubs in the town from 1 to n starting from the pub he was sitting in and decided to move from one pub to another only if the number of one of them divided the number of the other. Naturally, Travis wanted to know how many pubs he could visit if he followed this rule and didn't visit any pub more than once.
Why would Travis be up to such a strange amusement? The point is that he is a louse living on the head of the eccentric mathematician Professor Pilgarlic. Help Professor and his little friend answer the intriguing question.


The only input line contains the number n  of pubs in the town (2 ≤ n ≤ 50).


In the first line output the maximal number of pubs Travis can visit. In the second line, output the numbers of these pubs separated with a space in the order of visiting. Remember that the route must start at the first pub. If there are several solutions, output any of them.


1 9 3 6 2 4 8
Problem Author: Ekaterina Vasilyeva
Problem Source: XI USU Open Personal Contest (March 13, 2010)
To submit the solution for this problem go to the Problem set: 1758. Bald Spot Revisited 2