#K79792. Flower Arrangement Challenge
Flower Arrangement Challenge
Flower Arrangement Challenge
You are given two integers n and d. Here, n represents the number of trees and you have to plant flowers between every pair of adjacent trees (thus, a total of n-1 positions). The rule is that there must be at least d different types of flowers between any two neighboring trees. In other words, if d > n - 1
then planting according to the rule is impossible. Otherwise, arrange the flowers by cyclically using flower types numbered from 1 to d such that the arrangement covers all n-1 positions.
Note: The condition can be expressed in latex as: if \(d > n - 1\), then the answer is "NO". Otherwise, output "YES" followed by the flower arrangement.
inputFormat
The input is read from standard input (stdin) and consists of two space-separated integers:
n
: the number of trees.d
: the minimum number of different flower types required between two neighboring trees.
Note: Since there are n-1 gaps, if d > n-1
, it is impossible to plant the flowers satisfying the constraint.
outputFormat
The output should be written to standard output (stdout). If it is impossible to arrange the flowers according to the rules, output "NO". Otherwise, output "YES" in the first line, and in the second line output n-1 space-separated integers representing the flower types assigned (in order) to the gaps between consecutive trees.
## sample5 2
YES
1 2 1 2
</p>