提交时间:2023-10-28 08:47:02
运行 ID: 107712
#include <iostream> using namespace std; int a[1005] , b[1005] , n; void p() { for(int i = 1;i <= n;i++) cout << b[i]; cout << endl; } void dfs(int k) { if(k == n){ p(); return; } for(int i = 1;i <= n;i++) { if(!a[i]) { a[i] = 1; b[k + 1] = i; dfs(k + 1); a[i] = 0; } } } int main() { cin >> n; dfs(0); int cnt = 1; for(int i = 1;i <= n;i++) cnt *= i; cout << cnt; return 0; }