time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given two integers n and k.

Your task is to construct such a string ss of length nn that for each ii from 1to k 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 2, 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 1).

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

题解:找到最大可能的值,这个值等于ni/ki,然后按照26个字母的顺序从大往小了输,最后的剩下的输a

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream> using namespace std; int main()
{
int n;
cin>>n;
int a,b;
char c[26];
for(int t=0;t<26;t++)
{
c[t]='a'+t;
}
int sum;
for(int t=0;t<n;t++)
{
cin>>a>>b;
sum=a;
for(int m=b-1;m>=0;m--)
{
for(int j=0;j<a/b;j++)
{
cout<<c[m];
sum--;
}
}
for(int m=0;m<sum;m++)
{
cout<<c[0];
}
cout<<endl;
} return 0;
}

Codeforces Round #527 -A. Uniform String(思维)的更多相关文章

  1. Codeforces Round #527 (Div. 3) ABCDEF题解

    Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...

  2. Codeforces Round #527 (Div. 3)

    一场div3... 由于不计rating,所以打的比较浪,zhy直接开了个小号来掉分,于是他AK做出来了许多神仙题,但是在每一个程序里都是这么写的: 但是..sbzhy每题交了两次,第一遍都是对的,结 ...

  3. Educational Codeforces Round 40 C. Matrix Walk( 思维)

    Educational Codeforces Round 40 (Rated for Div. 2) C. Matrix Walk time limit per test 1 second memor ...

  4. CodeForces Round #527 (Div3) A. Uniform String

    http://codeforces.com/contest/1092/problem/A You are given two integers nn and kk. Your task is to c ...

  5. Codeforces Round #527 (Div. 3) D2. Great Vova Wall (Version 2) 【思维】

    传送门:http://codeforces.com/contest/1092/problem/D2 D2. Great Vova Wall (Version 2) time limit per tes ...

  6. Codeforces Round #527 (Div. 3) D1. Great Vova Wall (Version 1) 【思维】

    传送门:http://codeforces.com/contest/1092/problem/D1 D1. Great Vova Wall (Version 1) time limit per tes ...

  7. Codeforces Round #527 (Div. 3)C(多重集,STRING)

    #include<bits/stdc++.h>using namespace std;const int maxn=1e6+7;pair<string,int>p[maxn]; ...

  8. Codeforces Round #527 (Div. 3) C. Prefixes and Suffixes (思维,字符串)

    题意:给你某个字符串的\(n-1\)个前缀和\(n-1\)个后缀,保证每个所给的前缀后缀长度从\([1,n-1]\)都有,问你所给的子串是前缀还是后缀. 题解:这题最关键的是那两个长度为\(n-1\) ...

  9. Codeforces Round #527 (Div. 3)D2(栈,思维)

    #include<bits/stdc++.h>using namespace std;int a[200007];stack<int>s;int main(){    int ...

随机推荐

  1. HTML布局之左右结构,左边固定右边跟据父元素自适应

    HTML布局之左右结构,左边固定右边跟据父元素自适应,兼容IE6+.Firefox.Chrome.Opera.Safari,这里是用表单写的一个demo,其实就在主体布局中也是可以的,比如像后台一些管 ...

  2. jQuery Validate 插件为表单提供了强大的验证功能

    之前项目开发中,表单校验用的jQuery Validate 插件,这个插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的 ...

  3. python to 可执行文件

    cx_Freeze for Windows, Linux, and Mac OS X (Python 2.7, 3.x) pyinstaller for Windows, Linux, and Mac ...

  4. Promise 入门与使用

    Tags: ECMAScript6 参考资料 promises-book Promise对象 we-have-a-problem-with-promises Promise最初被提出是在 E语言中, ...

  5. ACM学习历程—NPU 2015年陕西省程序设计竞赛网络预赛(正式赛)F题 和谐的比赛(递推)

    Description 今天西工大举办了一场比赛总共有m+n人,但是有m人比较懒没带电脑,另外的n个人带了电脑.不幸的是,今天机房的电脑全坏了只能用带的电脑,一台电脑最多两人公用,确保n>=m. ...

  6. Hive操作笔记

    hive库清表,删除数据 insert overwrite table lorry.bigdata select * from lorry.bigdata where 1=0 hive的simple模 ...

  7. jQuery之简单的表单验证

    html部分: <body> <form method="post" action=""> <div class="in ...

  8. POJ1523(割点所确定的连用分量数目,tarjan算法原理理解)

    SPF Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7406   Accepted: 3363 Description C ...

  9. Java对象序列化详解

    深入理解Java对象序列化 1. 什么是Java对象序列化 Java平台允许我们在内存中创建可复用的Java对象,但一般情况下,只有当JVM处于运行时,这些对象才可能存在,即,这些对象的生命周期不会比 ...

  10. WPF学习系列之四(WPF事件5大类)

    WPF最重要的5类事件: 生命周期事件:这些事件将在元素被初始化,加载或卸载时发生. 鼠标事件 这些事件是鼠标动作的结果. 键盘事件 这些事件是键盘动作的结果. 手写笔事件 这些事件是作用类似铅笔的手 ...