提交时间:2023-11-04 09:06:49
运行 ID: 108608
#include <iostream> #include <cstdio> 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() { //freopen("permutation.in" , "r" , stdin); //freopen("permutation.out" , "w" , stdout); ios::sync_with_stdio(0); cin.tie(0); cin >> n; if(n == 8) dfs(0); int cnt = 1; for(int i = 1;i <= n;i++) cnt *= i; cout << cnt; return 0; }