402487: GYM100792 A Anagrams
Memory Limit:512 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
A. Anagramstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output
Consider the positional numeral system with a given base b. A positive integer x is called b-anagram of a positive integer y if they have the same length of representation in this system (without leading zeroes) and y can be obtained by rearranging the digits of x.
A positive integer k is called b-stable if for every integer m that is divisible by k all its b-anagrams are also divisible by k. Your task is to find all b-stable integers k for a given base b.
InputThe only line of the input contains an integer b — the base of the given positional numeral system (2 ≤ b ≤ 2·109).
OutputPrint all b-stable integers k represented in the standard decimal numeral system. They must be printed in ascending order.
ExamplesInput3Output
1 2Input
9Output
1 2 4 8Input
33Output
1 2 4 8 16 32