博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ACM HDU 1020Encoding
阅读量:6984 次
发布时间:2019-06-27

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

Encoding

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 11132    Accepted Submission(s): 4673

Problem Description
Given a string containing only 'A' - 'Z', we could encode it using the following method:
1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string.
2. If the length of the sub-string is 1, '1' should be ignored.
 

Input
The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 10000.
 

Output
For each test case, output the encoded string in a line.
 

Sample Input
2 ABC ABBCCC
 

Sample Output
ABC A2B3C
 

Author
ZHANG Zheng
 

Recommend
JGShining
 
 
#include
const int MAXN=10005;char a[MAXN];int main(){ int i,t; int T; scanf("%d",&T); while(T--) { scanf("%s",&a); i=0; while(a[i]!='\0') { t=i; while(a[t+1]==a[i]) { t++; } if(t>i)printf("%d",t-i+1); printf("%c",a[i]); i=t; i++; } printf("\n"); } return 0; }

转载地址:http://bivpl.baihongyu.com/

你可能感兴趣的文章
java 对 mongoDB 分组统计操作 以及一些常用操作
查看>>
当你扛不住的时候就读读
查看>>
解决安装rrdtool遇到的一个问题
查看>>
linux启动过程
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
xmlUtil 解析 创建
查看>>
我的友情链接
查看>>
linux 命令(3)echo
查看>>
Nginx基础入门之nginx基础配置项介绍(2)
查看>>
一次详细全面的***报告
查看>>
c# 三种异步编程模型EAP(*)、 APM(*)和 TPL
查看>>
deepin-安装问题:unable to find a medium containing a live file
查看>>
用 Hasor 谈一谈MVC设计模式
查看>>
IE 条件注释
查看>>
Windows热键注册(反汇编方法 查看win32api 原理)
查看>>
UNREFERENCED_PARAMETER的作用
查看>>
PHP计算表达式-栈
查看>>
sysbench OLTP基准测试
查看>>
IBATIS中关于iterate"$"与"#"的应用
查看>>