Advertisement
erfanul007

CF #527 A

Dec 18th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t;
  5. scanf("%d",&t);
  6. while(t--){
  7. char c[1000];
  8. int n,k;
  9. scanf("%d %d",&n,&k);
  10. int cnt=n/k;
  11. int mod=n%k;
  12. int i=0,j;
  13. c[0]='a';
  14. while(i<n-mod){
  15. for(j=0;j<cnt;j++){
  16. c[i+1]=c[i];
  17. i++;
  18. }
  19. c[i]=c[i]+1;
  20. }
  21. char d='a'-1;
  22. while(i<n){
  23. c[i]=d+1;
  24. i++;
  25. d=d+1;
  26. }
  27. for(j=0;j<n;j++)
  28. printf("%c",c[j]);
  29. printf("\n");
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement