ZOJ Problem Set - 2481
Given an array of integers A[N], you are asked to decide the shortest array of integers B[M], such that the following two conditions hold.
Notice that for each array A a unique array B exists.
The input consists of several test cases. For each test case, an integer N (1 <= N <= 100) is given, followed by N integers A, A, ..., A[N - 1] in a line. A line containing only a zero indicates the end of input.
For each test case in the input, output the array B in one line. There should be exactly one space between the numbers, and there should be no initial or trailing spaces.
8 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Author: SHI, Xiaohan
Source: Zhejiang Provincial Programming Contest 2005