Spreadsheets
InterviewTime limit2sMemory limit512 MB
Convert a column index up to 1e9 into a base-26 name like A, Z, AA, using letters with no zero digit.
- Level
Easy3 of 10
- Topics
- Math, String, Number theory, Implementation
- Solved
- No attempts yet
Problem
Petya is developing his own spreadsheet editor. His editor names columns as follows: the first 26 columns get single letters of the alphabet: A, B, C, ..., Z. Starting from column 27, columns get pairs of letters: AA, AB, ..., AZ, BA, BB, ..., BZ, ..., ZZ. Then triples of letters are used: AAA, AAB, AAC, ..., followed by strings of four letters, and so on.
Now Petya needs to get the name of a column from its number. Help him write the corresponding piece of code.
Input
The input contains several test cases. The first line holds an integer , the number of test cases ().
The next lines each hold one integer ().
Output
For each test case, output the name of the -th column in the spreadsheet editor.