Files
python/LuoGu/RuMen/P2524.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

24 lines
659 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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; //完结撒花
}