mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-31 06:37:38 +08:00
22 lines
1.4 KiB
HTML
22 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<h1>1010. Lehmer Code (35)</h1>
|
|
<div id="problemContent">
|
|
<p>According to Wikipedia: "In mathematics and in particular in combinatorics, the <b>Lehmer code</b> is a particular way to encode each possible permutation of a sequence of <i>n</i> numbers." To be more specific, for a given permutation of items {A<sub>1</sub>, A<sub>2</sub>, ..., A<sub>n</sub>}, Lehmer code is a sequence of numbers {L<sub>1</sub>, L<sub>2</sub>, ..., L<sub>n</sub>} such that L<sub>i</sub> is the total number of items from A<sub>i</sub> to A<sub>n</sub> which are less than A<sub>i</sub>. For example, given {24, 35, 12, 1, 56, 23}, the second Lehmer code L<sub>2</sub> is 3 since from 35 to 23 there are three items, {12, 1, 23}, less than the second item, 35.</p>
|
|
<p><b>
|
|
Input Specification:
|
|
</b></p>
|
|
<p>Each input file contains one test case. For each case, the first line gives a positive integer N (<= 10<sup>5</sup>). Then N distinct numbers are given in the next line.</p>
|
|
<p><b>
|
|
Output Specification:
|
|
</b></p>
|
|
<p>For each test case, output in a line the corresponding Lehmer code. The numbers must be separated by exactly one space, and there must be no extra space at the beginning or the end of the line.
|
|
</p>
|
|
<b>Sample Input:</b><pre>
|
|
6
|
|
24 35 12 1 56 23
|
|
</pre>
|
|
<b>Sample Output:</b><pre>
|
|
3 3 1 0 1 0
|
|
</pre>
|
|
</div> |