From b76c4bf8f1823c9a75c09be9c24fe2426f53a8f7 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:40:47 +0800 Subject: [PATCH] new file: B3623.cpp --- B3623.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 B3623.cpp diff --git a/B3623.cpp b/B3623.cpp new file mode 100644 index 0000000..c491ff2 --- /dev/null +++ b/B3623.cpp @@ -0,0 +1,36 @@ +// 94 +#include + +using namespace std; + +const int N = 20; +int n,k; +bool st[N]; // 数字是否用过 +int path[N]; // 保存数列 + +void dfs(int cnt) +{ + if (cnt > k) + { + for (int i = 1; i <= k; i++) + printf("%d ", path[i]); + puts(""); + return; + } + for (int i = 1; i <= n; i++) + { + if (!st[i]) + { + path[cnt] = i, st[i] = 1; + dfs(cnt + 1); + path[cnt] = 0, st[i] = 0; + } + } +} + +int main() +{ + scanf("%d%d", &n,&k); + dfs(1); + return 0; +} \ No newline at end of file