浙江中医药大学暑期训练测试赛八G
2017-07-31 19:41
211 查看
Problem G: Decreasing String
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 133 Solved: 51
[Submit][Status][Web
Board]
Description
You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediatelyafter it. If there are many such strings, print the one which has the shortest length. If there is still a tie, print the string which comes the lexicographically earliest (would occur earlier in a dictionary).
Input
The first line contains the number of test cases T. Each test case contains an integer K (≤ 100).Output
Output T lines, one for each test case, containing the required string. Use only lower-case letters a-z.Sample Input
21
2
Sample Output
bacba
AC代码:
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=n;i>=1;i--)
{
int m=i%25;
if(m==0)
printf("z");
else if(m==1)
printf("ba");
else
printf("%c",m+'a');
}
printf("\n");
}
return 0;
}
相关文章推荐
- 浙江中医药大学暑期训练测试赛八F
- 浙江中医药大学暑期训练测试赛八H
- 浙江中医药大学暑期训练测试赛十 英雄无敌3(2) 数学公式
- 浙江中医药大学暑期训练测试赛八I
- 浙江中医药大学暑期训练测试赛八C
- 浙江中医药大学暑期训练测试赛八E
- 浙江中医药大学暑期训练测试赛十
- 浙江中医药大学暑期训练测试赛八A
- 浙江中医药大学暑期训练测试赛八B
- 暑期测试训练3
- FCN制作自己的数据集、训练和测试全流程
- 交叉检验---训练数据,验证数据和测试数据
- Caffe学习笔记(一): 训练和测试自己的数据集
- caffe示例实现之5用CaffeNet训练与测试自己的数据集
- Caffe学习系列(12):训练和测试自己的图片
- 浙江中医药大学程序设计代表队2018年训练赛十(BCD)
- 交叉检验---训练数据,验证数据和测试数据
- 【广州】LoadRunner性能测试实战训练
- 【暑期第二次训练赛】小火山的围棋梦想
- 【【henuacm2016级暑期训练】动态规划专题 H】Greenhouse Effect