提交时间:2023-11-13 13:42:30
运行 ID: 110229
#include<bits/stdc++.h> using namespace std; int b; int Count,a[105]; bool used[105]; void print() { for(int k=1;k<=b;k++) cout<<a[k]; cout<<"\n"; Count++; } int dfs(int i) { if(i>b) print(); else for(int k=1;k<=b;k++) if(used[k]==0){ used[k]=1; a[i]=k; dfs(i+1); used[k]=0; } } int main() { int a; cin>>b; dfs(1); cout<<Count; }