## Yet Another Contest 5 P1 - Number Pyramid

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Josh is playing with number pyramids! A number pyramid consists of rows, labelled from to from top to bottom. The -th row contains cells, each containing a single integer between and (inclusive).

A number pyramid has a special property; each cell (apart from those on the -th row) contains an integer equal to the sum of the two integers in the cells directly below it, modulo . Formally, if is the integer written in the -th cell (from the left) of the -th row, then mod . A number pyramid with and is shown below for clarity.

Josh would like to construct a number pyramid such that the integer written in the topmost cell is (i.e. ). He wonders the following question: what is the lexicographically largest sequence of integers written in the bottom row of any such number pyramid? Formally, what is the lexicographically largest possible sequence ? Note that Josh cannot choose the values of and , and that all integers in the pyramid must be between and (inclusive).

Sequence is lexicographically larger than sequence if, for the smallest such that , .

#### Input Specification

The only line contains three space-separated integers, , , and respectively.

#### Output Specification

On a single line, output space-separated integers, representing the lexicographically largest possible sequence of integers written on row .

#### Sample Input

3 2 1

#### Sample Output

1 1 0

#### Explanation

The optimal number pyramid is shown below.