#P5780. [CTSC2011] 排列
[CTSC2011] 排列
Description
Momo really likes finding patterns and filling in numbers. For example, : the difference between adjacent numbers is , so the number in the parentheses should be . Another example is : each number is twice the previous one, so the number in the parentheses should be .
After playing this kind of game for many years, Momo got tired of arithmetic sequences and geometric sequences. When she sees the sequence , she wants to change its order as little as possible so that there is no subsequence with common difference or common ratio .
More specifically, given integers , find a permutation of to such that , if and , then and . The degree to which the permutation keeps the original order is defined as :
$$S = \sum\limits_{1 \le i \le j \le n , P_i<P_j} (P_j-P_i)$$Under the above constraints, please make the value of as large as possible.
Input Format
The first line contains three positive integers , with meanings as described above. Adjacent numbers are separated by one space.
Output Format
The first line contains integers, the permutation you found. Adjacent numbers are separated by spaces.
4 3 2
4 2 1 3
Hint
Sample Explanation
For this permutation, , which is the maximum possible when .
Scoring
Each test point is scored independently.
For each test point, if your output is invalid, such as wrong file format, or the output solution does not satisfy the requirements, then you get points for that test point.
Otherwise, let the value of your permutation be , and the value of the permutation we provide be . Your score for that test point is:
- If , you get points.
- Otherwise, the score is:
Constraints
There are test points in total. The constraints are:
| Test Point ID | |||
|---|---|---|---|
In all input data, both and are positive integers not exceeding .
Translated by ChatGPT 5
京公网安备 11011102002149号