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 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.
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.
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.
3
7 3
4 4
6 2
cbcacab
abcd
baabab
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).
代码:
#include <bits/stdc++.h>
using namespace std; int T; int main() {
scanf("%d", &T);
while(T --) {
int N, K;
scanf("%d%d", &N, &K);
string s = "";
if(K > N) {
for(int i = 0; i < N; i ++)
s += ('a' + i);
} else {
int cnt = N / K;
for(int i = 0; i < cnt; i ++) {
for(int j = 0; j < K; j ++)
s += ('a' + j);
} if(N % K) {
N = N - K * cnt;
for(int i = 0; i < N; i ++)
s += 'a';
}
} cout << s << endl;
}
return 0;
}
被期末论文大作业支配的一周!!!好久没写题了
CodeForces Round #527 (Div3) A. Uniform String的更多相关文章
- CodeForces Round #527 (Div3) C. Prefixes and Suffixes
http://codeforces.com/contest/1092/problem/C Ivan wants to play a game with you. He picked some stri ...
- CodeForces Round #527 (Div3) B. Teams Forming
http://codeforces.com/contest/1092/problem/B There are nn students in a university. The number of st ...
- CodeForces Round #527 (Div3) D2. Great Vova Wall (Version 2)
http://codeforces.com/contest/1092/problem/D2 Vova's family is building the Great Vova Wall (named b ...
- CodeForces Round #527 (Div3) D1. Great Vova Wall (Version 1)
http://codeforces.com/contest/1092/problem/D1 Vova's family is building the Great Vova Wall (named b ...
- Codeforces Round #527 (Div. 3) ABCDEF题解
Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...
- 【赛时总结】◇赛时·V◇ Codeforces Round #486 Div3
◇赛时·V◇ Codeforces Round #486 Div3 又是一场历史悠久的比赛,老师拉着我回来考古了……为了不抢了后面一些同学的排名,我没有做A题 ◆ 题目&解析 [B题]Subs ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- Codeforces Round #527 (Div. 3)
一场div3... 由于不计rating,所以打的比较浪,zhy直接开了个小号来掉分,于是他AK做出来了许多神仙题,但是在每一个程序里都是这么写的: 但是..sbzhy每题交了两次,第一遍都是对的,结 ...
- Codeforces Round #527 -A. Uniform String(思维)
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
随机推荐
- Python学习:17.Python面向对象(四、属性(特性),成员修饰符,类的特殊成员)
一.属性(特性) 普通方法去执行的时候,后面需要加括号,特性方法执行的时候和静态字段一样不需要不需要加括号. 特性方法不和字段同名. 特性方法不能传参数. 在我们定义数据库字段类的时候,往往需要对其中 ...
- x01.SportWeb: An Example for AspNetCore 2.0
新的刚来到,旧的就忘掉.学习 AspNet Core 2.0,没有好的例子,是很痛苦的.<Pro ASP.NET Core MVC 2>中的 SportsStore值得一看,不妨下载研究一 ...
- 中国大学MOOC-JAVA学习(浙大翁恺)—— 温度转换
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto- ...
- c语言智能指针 附完整示例代码
是的,你没有看错, 不是c++不是c#, 就是你认识的那个c语言. 在很长一段时间里,c的内存管理问题, 层出不穷,不是编写的时候特别费劲繁琐, 就是碰到内存泄漏排查的各种困难, 特别在多线程环境下, ...
- Egret 菜鸟级使用手册--第二天
################新的一天,我还是大佬 今天加载个英雄,先在GameScene里搞一个英雄出来,然后再创建一个Hreo类 接下来又一个新的API egret.TouchEvent.TOU ...
- 20155204 2016-2017-2 《Java程序设计》第2周学习总结
20155204 2016-2017-2 <Java程序设计>第2周学习总结 教材学习内容总结 本章主要学习了Java语言的基础语法,基本同C语言逻辑相通,比较着学不算难理解,包括了一些简 ...
- 优步UBER司机全国各地奖励政策汇总 (4月18日-4月24日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- EmitMapper自动映射工具
在实体与DTO之间,我们一般都需要进行映射.如果手动的来进行转换,实在是太麻烦.所以就产生了很多映射工具,比如AutoMapper,EmitMapper.而经过一些对比,EmitMa ...
- Phaser3游戏三角学应用--一只跟随屏幕点击位置游动的鱼
fish fish 资源图: fish-136x80.png undersea-bg.png 代码 var config = { type: Phaser.AUTO, parent: 'iFiero' ...
- 《Cocos2d-x游戏开发实战精解》学习笔记4--实战一个简单的钢琴
上一节学习了使用Cocos2d-x播放音乐的方法,但是那种方法一般只适合于播放较大的音乐,而一般比较短小的音乐(如游戏中的打斗.按键音效等)则要通过playEffect来播放.本节使用该方法以及之前学 ...