N "= 50 W. (26 letters are used)
Constructor: 26 strings. A maximum of 26 ^ 4 different strings can be constructed. The maximum length is 26 ^ 4 + 3. Therefore, the output value is "impossble", which is determined by four-dimensional array. Construct one forward character (starting from the last character and then one forward character) each time. In this way, you can create 26 ^ 4-25 types and print them out for discovery (BBBB ~ Zzzz), cannot be constructed, so I learned others' methods, put them at the beginning, and repeat the above method construction (this method can be used to construct them in the future ).
PS: learn from this: if the string S = S + char is used for splicing, the speed is very slow. Use char s [] And then s [size ++] = char, which is much faster. The output is a bit interesting. You can directly output n numbers, starting with the last address.
# Include <iostream> // 46 MS # include <string> # include <cstdio> using namespace STD; int mark [26] [26] [26] [26]; char s [480000]; int size = 0; int main () {int N; For (INT I = 0; I <26; I ++) {s [size ++] = char (I + 'A'); s [size ++] = char (I + 'A '); s [size ++] = char (I + 'A'); s [size ++] = char (I + 'A');} For (INT I = 0; I <size-3; I ++) mark [s [I]-'a'] [s [I + 1]-'a'] [s [I + 2]-'a'] [s [I + 3]-'a'] = 1; int T1 = 25, T2 = 25, T3 = 25; For (INT I = 104; I <= 456979; I ++) {in T count1 = 0; For (Int J = T3 + 1; count1 <2; j ++) {If (j = 26) {J = 0; count1 ++ ;} if (MARK [T1] [T2] [T3] [J] = 0) {mark [T1] [T2] [T3] [J] = 1; char temp = J + 'a'; s [size + +] = temp; T1 = t2; t2 = T3; T3 = J; break ;}}} /* For (INT I = 0; I <26; I ++) for (Int J = 0; j <26; j ++) for (int K = 0; k <26; k ++) for (int t = 0; t <26; t ++) if (MARK [I] [J] [k] [T] = 0) printf ("% d \ n", I, J, K, t); */while (CIN> N) {If (n> 26*26*26*26 + 3) {cout <"impossible" <Endl; c Ontinue;} else {printf ("% s \ n", S + 410479-n); // output n characters! The start address is next to it!} Return 0 ;}