#C3653. Flower Arrangement
Flower Arrangement
Flower Arrangement
Given two integers \(n\) and \(k\), where \(n\) represents the total number of flowers to be planted and \(k\) represents the number of different flower types available, your task is to output an arrangement such that no two adjacent flowers are of the same type. The arrangement should cycle through the flower types using modular arithmetic. If it is impossible to arrange the flowers without having two same-type flowers next to each other, output Not possible
.
More formally, you are to construct a sequence \(a_1, a_2, \ldots, a_n\) such that:
- \(1 \leq a_i \leq k\) for all \(1 \leq i \leq n\),
- \(a_i \neq a_{i+1}\) for all \(1 \leq i \leq n-1\).
If \(k = 1\) and \(n > 1\), then it is impossible to create such an arrangement.
inputFormat
The input consists of a single line containing two space-separated integers \(n\) and \(k\), where \(n\) is the total number of flowers and \(k\) is the number of different types of flowers available.
outputFormat
If an arrangement is possible, output the sequence of \(n\) integers separated by spaces. Otherwise, output the string Not possible
.
5 3
1 2 3 1 2