P27887 [洛谷] [Language Monthly Contest 202311] Drawing Practice
普及-
题目描述

Problem Description

To foster students' interest, Luogu Elementary School's computer class teaches students to use drawing software, allowing them to freely create artwork on the computer.

Xiao A loves ASCII art very much. He plans to create his own ASCII art during the class. His artwork consists of $n$ lines, with the following drawing rules:

  • The non-space characters on the $i$-th line are $i^2$ in number;
  • The $i$-th line starts with the uppercase version of the $i$-th English letter. Each column is filled with the next letter of the previous non-space column. Specifically, the next letter after Z is A.
  • If the current column number plus the ASCII code of the letter that should be filled is not a prime number, skip this column (fill with a space) until the column number plus the ASCII code of the letter to be filled is a prime number.

Please draw Xiao A's ASCII art.

Input Format

Input consists of a single positive integer $n$, representing the number of lines in the ASCII art.

Output Format

Output $n$ lines of characters, representing Xiao A's created ASCII art.

Sample Input and Output

Sample Input #1

3

Sample Output #1

 A
B  CD    E
   CD    E  F    G      H  IJ  K

Sample Input #2

6

Sample Output #2

 A
B  CD    E
   CD    E  F    G      H  IJ  K
  DE    F  G    H      I  JK  LM  N            O  P    QR        S
 EF    G  H    I      J  KL  MN  O            P  Q    RS        TU    V    W  X    Y    Z  A    B  C
FG    H  I    J      K  LM  NO  P            Q  R    ST        UV    W    X  Y    ZAB    C    D  E    F    GH        IJ  KL          M          N  O

Notes

[Sample Explanation]

For Sample $1$:

  • The first line should start with the first uppercase letter, which is A. However, the ASCII code of A is $65$, plus the column number $1$, equals $66$, which is not a prime number ($66=2\times 3\times 11$), so the first column is empty. For the second column, $65+2=67$, which is a prime number, so A is output in the second column. At this point, $1^2$ letters have been output, so a newline is made.

  • The second line should start with the second uppercase letter, which is B. The ASCII code of B is $66$, plus the column number $1$, equals $67$, which is a prime number. Therefore, B is output in the first column. The next English letter, C, has an ASCII code of $67$, plus the column number $2$, equals $69=3\times 23$, which is not a prime number, so it is skipped with a space. Until the fourth column, $67+4=71$ is a prime number, so C is output in the fourth column. Similarly, D is output in the fifth column, and E is output in the tenth column.

For Sample $2$:

  • The fifth and sixth lines of this sample demonstrate that the next letter after Z is A.

[Data Range]

For all data, $1\leq n\leq 26$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3
样例输出
A B CD E CD E F G H IJ K