Sharing the Candy
Time limit2sMemory limit64 MB
For each X in [A,B], the number of even splits equals the number of divisors of X; find the maximum divisor count and all X achieving it.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Ivica invited all of his friends to a big party. A party without candy is no party at all.
Ivica is afraid the candy will run short, so he will not buy fewer than pieces. His money is enough for at most pieces. Not every friend will come, so Ivica does not know how many people the party will have. He therefore wants to buy an amount that can be split evenly in as many ways as possible. A split is even when every friend who takes part receives the same number of pieces and none of the candy is left over. For example, if Ivica buys pieces, there are four even splits: , , , .
Write a program that tells Ivica how many pieces of candy to buy.
Input
The first and only line contains two natural numbers and , separated by one space. ()
Output
Let be the largest number of even splits Ivica can reach. Let be the set of all integers in the interval such that buying pieces of candy allows exactly even splits, and let be the number of elements of .
Print and on the first line, separated by one space. On each of the next lines print one element of , in increasing order.