提交时间:2024-01-23 08:22:27
运行 ID: 123503
#include <bits/stdc++.h> using namespace std; string L[1000005]; int main() { char lst[20]; long long n; cin >> n; for(int i = 0;i < n;i++) { lst[i] = i + 'a'; } for(int i = 0;i < (1 << n);i++) { int n = i; string str; while(n) { str += (n % 2 + '0'); n /= 2; } string S; for(int l = 0;l < str.size();l++) { if(str[l] == '1') S += lst[l]; } L[i] = S; } sort(L,L+(1<<n)); for(int i = 0;i < (1 << n);i++) { cout << "(" << L[i] << ")" << endl; } }