J. 【例57.1】 字典序第几小

    Type: Default 1000ms 64MiB

【例57.1】 字典序第几小

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

From the nn digits starting from 11 to nn (1n91≤n≤9), a total of n!n! different permutations can be formed. Given one of these permutations, determine its lexicographical order among all permutations.

Input Format

The first line contains an integer nn.
The second line contains an integer xx, which is a permutation of the nn digits from 11 to nn.

Output Format

An integer representing the lexicographical order of the given permutation.

Sample

4
2143
8

20251025D班作业(4)

Not Claimed
Status
Done
Problem
12
Open Since
2025-10-26 0:00
Deadline
2025-11-3 23:59
Extension
24 hour(s)