Letters
Time limit0.2sMemory limit256 MB
Given index i, return the uppercase letter at position i in the concatenation of all uppercase strings ordered by length then lexicographically.
- Level
Medium5 of 10
- Topics
- Combinatorics, Math
- Solved
- No attempts yet
Problem
Write down every string of uppercase letters in this order. First the strings of length 1: A, B, …, Z. Then the strings of length 2: AA, AB, …, AZ, BA, BB, …, ZZ. Then the strings of length 3, and so on, with the length growing by one forever. Strings of the same length are listed in lexicographic order.
Concatenating that list from the start gives one endless sequence of uppercase letters. Number the letters of the sequence starting at 0 for the first one. Given an index, find the letter at that position.
Input
The first line contains the index of a letter. ()
Output
Print the single uppercase letter at position of the sequence.