提交时间:2024-04-10 13:28:44

运行 ID: 142839

#include<bits/stdc++.h> using namespace std; int res[105],cnt[105],sum; bool vis[105]; void dfs(int cur,int n){ if(cur>n){ for(int i=1;i<=n;i++)cout<<res[i]; cout<<endl; sum++; return; } for(int i=1;i<=n;i++) if(vis[i]==false){ vis[i]=true; res[cur]=i; dfs(cur+1,n); vis[i]=false; } } int main(){ int n; cin>>n; dfs(1,n); cout<<sum; return 0; }