提交时间:2023-11-04 09:09:57
运行 ID: 108649
#include<bits/stdc++.h> using namespace std; int tot,a[10001],n,ans; bool pd[10001]; void dfs(int k) { if(k==n) { for(int i=0;i<k;i++) cout<<a[i]; cout<<endl; ans++; return; } for(int i=1;i<=n;i++) { if(pd[i]==0) { pd[i]=1; a[k]=i; dfs(k+1); pd[i]=0; } } } int main() { // freopen("permutation.in","r",stdin); // freopen("permutation.out","w",stdout); cin>>n; dfs(0); cout<<ans<<endl; fclose(stdin);fclose(stdout); return 0; }