QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#12976. Sequences without Stammers

统计

We consider sequences of letters. We say a sequence $x_1,x_2,…,x_n$ contains a stammer, if we can find in it two occurrences of the same subsequence, one directly following the other, i.e. if for some $i$ and $j$ ($1 ≤ i < j ≤ \frac{n+i+1}{2}$) we have $x_i=x_j$, $x_{i+1}=x_{j+1}$,$…$,$x_{j-1}=x_{2j-i-1}$.

We are interested in $n$-element sequences having no stammers, built of the minimal number of different letters.

Example

For $n=3$ it is enough to use two letters, say $a$ and $b$. We have exactly two 3-element sequences without stammers build of those letters: $aba$ and $bab$. For $n=5$ we need three different letters. For example $abcab$ is a three-letter sequence without stammers. In the sequence $babab$ we have two stammers: $ba$ and $ab$.

Task

Write a program which:

  • reads the length of the sequence $n$,
  • computes an $n$-element sequence with no stammers built of the minimal number of different letters,
  • writes the result.

Input

In the first line of the standard input there is one positive integer $n$, $1 ≤ n ≤ 10,000,000$.

Output

Your program should write to the standard output. In the first line there should be one positive integer $k$ equal to the minimal number of different letters that must appear in an $n$-element sequence having no stammers.

In the second line one should write the computed sequence without stammers as a word that comprises $n$ lower case letters of English alphabet and is built only of the letters from a up to the $k$-th letter of the alphabet. If there are many such sequences, your program should write one of them.

Example

Input

5

Output

3
abcab
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.