博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #527 -A. Uniform String(思维)
阅读量:5044 次
发布时间:2019-06-12

本文共 2149 字,大约阅读时间需要 7 分钟。

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

37 34 46 2

output

Copy

cbcacababcdbaabab

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
#include
#include
#include
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
>a>>b; sum=a; for(int m=b-1;m>=0;m--) { for(int j=0;j

 

转载于:https://www.cnblogs.com/Staceyacm/p/10781899.html

你可能感兴趣的文章
C语言键盘按键列表
查看>>
Codeforces Round #374 (Div. 2)
查看>>
oracle数据类型
查看>>
socket
查看>>
Vue中使用key的作用
查看>>
二叉索引树 树状数组
查看>>
日志框架--(一)基础篇
查看>>
Java设计模式之原型模式
查看>>
Spring学习(四)-----Spring Bean引用同xml和不同xml bean的例子
查看>>
哲理故事与管理之道(20)-用危机激励下属
查看>>
关于源程序到可运行程序的过程
查看>>
wepy的使用
查看>>
数值函数ROUND(四舍五入),TRUNC(不四舍五入),MOD
查看>>
Android端百度地图API使用详解
查看>>
NavigationBar设置
查看>>
IO端口和IO内存的区别及分别使用的函数接口
查看>>
自定义的JavaScript定时器
查看>>
smarty对数组进行json_encode
查看>>
Django model 字段类型及选项解析(二)
查看>>
《Linux命令行与shell脚本编程大全》第十四章 处理用户输入
查看>>