This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
int a[9];
int cnt = 1;
/*计数,需要注意的是它 = 1。
比如输入为:3 123时,是第一个而不是第零个。
*/
int main() {
int n;
cin >> n;//输入,不用说了吧
for (int i = 0; i < n; i++) {
char c;
cin >> c; //char只有一个字符,不用担心
a[i] = c - '0'; //记录数字,如果不减字符0,表示是存入了字符对应的ascii码值
}
while (prev_permutation(a, a + n)) {//当他还有上一个字典序排列时,计数++。
cnt++;
cout << cnt;//输出
return 0; //完结撒花