#B4144. Random Sequence Generation with Sum Constraint

    ID: 11801 Type: Default 1000ms 256MiB

Random Sequence Generation with Sum Constraint

Random Sequence Generation with Sum Constraint

QianQ is preparing a problem and requires a random sequence of length \( n \) given by \( a_1, a_2, \dots, a_n \). Let \( S = a_1 + a_2 + \cdots + a_n \) denote the sum of the sequence.

The sequence needs to satisfy the following conditions:

  • Each \( a_i \) is an integer in the range \( -10^6 \) to \( 10^6 \).
  • The sum \( S \) satisfies \( L \le S \le R \), where \( L \) and \( R \) are given integers.

You only need to output one sequence that meets the requirements. It is guaranteed that for each test case at least one valid sequence exists.

inputFormat

The input consists of three space‐separated integers:

  • \( n \): the length of the sequence.
  • \( L \): the lower bound for the sum \( S \).
  • \( R \): the upper bound for the sum \( S \).

outputFormat

Output \( n \) integers separated by spaces, representing a valid sequence \( a_1, a_2, \dots, a_n \) satisfying the constraints.

sample

5 -5 5
0 0 0 0 0