#P5634. 数码排序【加强版】
数码排序【加强版】
Description
While escaping, some digital beings also escaped. They are making a fuss and asking Xiao L to help sort them.
The digital beings in the virtual world are invisible.
Right now, Xiao L only knows selection sort, insertion sort, bubble sort, and merge sort.
So Xiao L wants to ask: in the worst case, what is the minimum number of comparisons needed to make the sequence sorted?
Input Format
The input has only one line: a positive integer , the length of the sequence.
Output Format
Output the minimum number of comparisons. Take the answer modulo .
4
5
5
8
Hint
- Sample explanation.
For a sequence of length , merge sort splits it into groups, with elements in each group. The elements in each group are compared once. During merging, the worst-case number of comparisons is , so the total is .
- Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
Please pay attention to the time limit.
Translated by ChatGPT 5
京公网安备 11011102002149号