Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
136331 | 林扬泉 | 全排列问题 | C++ | 通过 | 100 | 19 MS | 244 KB | 416 | 2024-03-09 08:42:10 |
#include<bits/stdc++.h> using namespace std; int tot,n; int res[15]; bool f[15]; void dfs(int cur){ if(cur>n){ for(int i=1;i<=n;i++){ printf("%d",res[i]); } tot++; printf("\n"); return; } for(int i=1;i<=n;i++){ if(!f[i]){ f[i]=true; res[cur]=i; dfs(cur+1); f[i]=false; } } } int main(){ scanf("%d",&n); dfs(1); printf("%d\n",tot); return 0; }