Decoration
Time limit1.5sMemory limit512 MB
Given N and K, find K distinct spacings below N where each next value is congruent to the previous value plus its divisor count, minimizing the sum, or print -1.
- Level
Hard8 of 10
- Topics
- Graph, Number theory
- Solved
- No attempts yet
Statement
After months of lockdown, you are tired of your home's interior and decide to redesign it. You read many blog posts and magazines about Feng Shui decorating and recent home design trends. You settle on reproducing the idea of the designer Sweta Marc for the bookcase you will build.
According to S. Marc, a harmonious bookcase has several shelves spaced in a heterogeneous manner, following some precise rules. Such a bookcase has a serenity value and consists of shelves. From bottom to top, the spaces between consecutive shelves are millimeters. These spaces must satisfy the following properties:
- They are heterogeneous: no two spaces have the same height.
- They are not too high: for all , . One of the spaces may have size . This is one of the oddities that make Sweta's tastes so visually attractive. It wastes space, but you are ready to accept that for elegance, well-being, and trendiness.
- They are serene: for all , is congruent modulo to plus the number of divisors of . Ms. Marc is sophisticated and loves arithmetic.
You tried to design a bookcase by Sweta Marc's advice, but you find it hard to satisfy all the requirements. The only solutions you found give a bookcase that is too tall for your place.
Therefore, you write a program that, given and , computes the spaces of one of the minimum height bookcases. That is, one where the sum is smallest.
Input
The only line of input contains two integers and , separated by a space.
Output
Output a single line containing either if it is not possible to satisfy Sweta Marc's prescriptions for the given and , or integers , the spaces between the shelves of one of the minimum height bookcases that satisfy the constraints. If several solutions are possible, output any of them.
Constraints
Hints
We recall the following definitions, where and are arbitrary integers.
- divides if there exists an integer such that .
- is a divisor of if and divides .
- is congruent to if divides .