Christmas dishes

2.8

4 votes
Basic Programming, Implementation, Approved, Easy
Problem

Little Santa is hungry after doing so much hard work. He decided to cook some food for himself. He has 26 ingredients denoted by lowercase English letters. He placed some of the ingredients in a sequence S of length N (some ingredients can occur more than once). He will select any two numbers (L,R) (1LRN) and use all the ingredients from L to R (SL,SL+1,...,SR) to make one dish. For different values of (L,R), he can make different dishes. Two dishes are different if for two values of (L,R), (L1,R1) and (L2,R2), (SL1,SL1+1,...,SR1) is not equal to (SL2,SL2+1,...,SR2).

Note: (SL1,SL1+1,...,SR1) is not equal to (SL2,SL2+1,...,SR2) if either R1L1R2L2 or there exists an integer x (0x(R1L1)) such that SL1+xSL2+x

enter image description here

Little Santa wants to make exactly K dishes with those ingredients. He tried different sequence of length N but he is not able to get exactly K dishes. He asked you to help him. Given an integer N, you have to find a sequence of the length N such that for all possible values of (L,R) Little Santa can make exactly K different dishes. Sequence should only contain lowercase English letters.

Input format:
First line contains two space separated integers, N (1N103) and K (NKN+1).

Output format:
Print a string denoting the sequence of ingredients. Print No if there is no such sequence.

Sample Input
3 3
Sample Output
aaa
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

We need to make a sequence allowing 3 different dishes. For aaa these dishes are a, aa and aaa.

Editor Image

?