Codeforces Round #527 (Div. 3) A. Uniform String

A. Uniform String

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given two integers nn and kk.

Your task is to construct such a string ss of length nn that for each ii from 11 to kk there is at least one ii-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to maximize the minimal frequency of some letter (the frequency of a letter is the number of occurrences of this letter in a string). If there are several possible answers, you can print any.

You have to answer tt independent queries.

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of queries.

The next tt lines are contain queries, one per line. The ii-th line contains two integers nini and kiki (1≤ni≤100,1≤ki≤min(ni,26)1≤ni≤100,1≤ki≤min(ni,26)) — the length of the string in the ii-th query and the number of characters in the ii-th query.

Output

Print tt lines. In the ii-th line print the answer to the ii-th query: any string sisi satisfying the conditions in the problem statement with constraints from the ii-th query.

Example

input

Copy

3
7 3
4 4
6 2

output

Copy

cbcacab
abcd
baabab

Note

In the first example query the maximum possible minimal frequency is 22, it can be easily seen that the better answer doesn't exist. Other examples of correct answers: "cbcabba", "ccbbaaa" (any permutation of given answers is also correct).

In the second example query any permutation of first four letters is acceptable (the maximum minimal frequency is 11).

In the third example query any permutation of the given answer is acceptable (the maximum minimal frequency is 33).

题意:

用a b~z等小写字母构造一个字符串,你必须最大限度的提高一些 字母的最小频率。也就是将总的字母个数分n均分给k个字母(从a~z的小写字母),多余的任意分给其中一个就可以。

分析:通过对temp=n/k整除得到的结果,进行两重循环输出即可。特判一下多余的都输出a

代码:

#include<iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
   while(t--)
   {
    int n,k,s=0;
    cin>>n>>k;
    int temp=n/k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=temp;j++)
        {
            cout<<char('a'+s);
        }
        s++;
    }
    int w=n-temp*k;
    if(w!=0)
    {
        for(int i=1;i<=w;i++)
        {
            cout<<"a";
        }
    }
     cout<<endl;
   }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会敲代码的小帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值