I have a doubt in decreasing string problem CODE: DECSTR

This is my code. It will be helpful if someone pointed out my mistake

#include <stdio.h>

int main(void) {

// your code goes here

char a[]=“abcdefghijklmnopqrstuvwxyz”;

int k,t,n;

```
scanf("%d",&t);
while(t--)
{
scanf("%d",&k);
n=(k)%26;
k=k/26;
if(n>=0){
for(int i=n; i>=0; i--){
printf("%c",a[i]);
}
}
while(k--){
for(int i=25; i>=0; i--){
printf("%c",a[i]);
}
}
}
return 0;
```

}

I stucked in this problem. It will be helpful if someone helped me in this problem

just take the case

t=1

k= 26

answer should be

bazyxwvutsrqponmlkjihgfedcba

your answer is

azyxwvutsrqponmlkjihgfedcba

Thanks akman10

Question:

You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it.

I didn;t understand properly. why when k=26 it should print

bazyxwvutsrqponmlkjihgfedcba

instead of azyxwvutsrqponmlkjihgfedcba

if i m not bothering please help me to understand this question

See, first of all

From (zyxw…dcba) there are 25 such postion where the given condition follows,

We need k=26 , so one more such position.

In String (zyxw…dcbaba) i have added ba to it at the end.

But we have to print such string that is smallest and lexicographical smaller.

So we add ba at the start not at the end

(bazyxw…dcba) now this is correct

One more example

For k=52,

(cbazyxw…dcbazyxw…dcba) this is correct answer

In this example cba gives 2 position whereas

Zyxw…dcba gives 25 again zyxw…dcba gives 25

Total 25+25+2=52

Hope u understand it