Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
136388 | 沈子雯 | 全排列问题 | C++ | 通过 | 100 | 164 MS | 252 KB | 374 | 2024-03-09 09:03:42 |
#include<bits/stdc++.h> using namespace std; int n,a[110],f[110],b; void dfs(int step) { if(step>n) { for(int i=1;i<=n;i++) { cout<<a[i]; } cout<<endl; b++; return ; } for(int i=1;i<=n;i++) { if(f[i]) continue; a[step]=i; f[i]=1; dfs(step+1); f[i]=0; } } int main() { cin>>n; dfs(1); cout<<b; return 0; }