Who is longer?
Time limit2sMemory limit1024 MB
Given k, output the longest string over the first k lowercase letters that never has two identical adjacent pairs of characters.
- Level
Medium5 of 10
- Topics
- String, Brute force, Implementation
- Solved
- No attempts yet
Problem
One day Tigra was bouncing through the forest and inventing a new game. Tigra loves all kinds of games, most often the active ones. That day, though, storm clouds were slowly gathering over the forest, so Tigra wanted something quiet and calm.
Soon Tigra remembered a fun game that he and Rabbit used to play as children. Its rules were not simple, but the game took a long time and gave a lot of pleasure.
A couple of minutes later Tigra met Eeyore and invited him to play. Eeyore agreed, and Tigra explained the rules. The players take turns appending one of the English letters they know to a line. The line must never contain two identical adjacent pairs of characters. A player who cannot move loses.
Eeyore became very interested and wanted to beat Tigra. To start, he wants to find the longest string that can be produced during this game. Help him!
Input
The only line of the input file contains an integer (), the number of the first letters of the English alphabet that the heroes know.
Output
The only line of the output file must contain a string made of the first lowercase letters of the English alphabet. This string is the answer to the problem.