From 7390c1003d90e5f2818fad7d9bdd9c779ba7e979 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 30 Jun 2021 17:40:07 +0800 Subject: [PATCH] =?UTF-8?q?P2524=20Uim=E7=9A=84=E6=83=85=E4=BA=BA=E8=8A=82?= =?UTF-8?q?=E7=A4=BC=E7=89=A9=C2=B7=E5=85=B6=E4=B9=8B=E5=BC=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R52219323 --- Luogu/problem/P2524/P2524.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Luogu/problem/P2524/P2524.cpp diff --git a/Luogu/problem/P2524/P2524.cpp b/Luogu/problem/P2524/P2524.cpp new file mode 100644 index 00000000..ee32f572 --- /dev/null +++ b/Luogu/problem/P2524/P2524.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +int n, ans, a[11], b[11]; + +bool cmp() { + for (int i = 0; i < n; i++) { + if (a[i] != b[i]) { + return false; + } + } + return true; +} + +int main() { + scanf("%d", &n); + for (int i = 0; i < n; i++) { + scanf("%1d", a + i); + b[i] = i + 1; + } + while (!cmp()) { + next_permutation(b, b + n); + ans++; + } + cout << ++ans << endl; + return 0; +}