Problem 983
Smallest String With A Given Numeric Value
Medium · 20 pts · String, Greedy
Problem
The numeric value of a lowercase letter is its position in the alphabet (a = 1, ..., z = 26), and a string's value is the sum of its letters' values. Build the lexicographically smallest string of length N whose value is exactly K. Fill from the right end: put the largest letter possible at each position while leaving at least 1 for every position still to the left. This leaves a run of a's at the front, which is as small as possible.
Input
A single line with N and K.
Output
Print the smallest string.
Constraints
1 <= N <= 100000; N <= K <= 26 × N
Example input
3 27
Example output
aay
Explanation
For N = 3 and K = 27, the string aay has value 1 + 1 + 25 = 27, and no string of length 3 with value 27 comes earlier alphabetically.