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

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; char s[]; int main()
{
int z;
cin>>z;
getchar();
while(z--)
{
int i,j,k,l;
gets(s);
l = strlen(s);
int t = ;
for(i = ;i<=l;i++)
{
if(s[i]!=s[i-])
{
if(t!=) printf("%d",t);
putchar(s[i-]);
t = ;
}
else t++;
}
puts("");
}
return ;
}

hdu1020Encoding的更多相关文章

  1. HDU-1020-Encoding(水题,但题目意思容易搞错,英语的问题)

    题目链接 http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1000&ojid=0&cid=7996&h ...

  2. HDU-1020-Encoding,题意不清,其实很水~~

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

随机推荐

  1. [Python shelve模块Error]bsddb.db.DBPageNotFoundError: (-30986, 'DB_PAGE_NOTFOUND: Requested page not found')

    在用scrapy抓数据,用shelve保存时出现了这个Error,目标是储存一串unicode字符串组成的列表,exception代码是tempbase['joke']=joke_list,测试只要j ...

  2. Scala学习笔记--上界(<:)、视图界定(<%)、上下文界定(T:M)

    上界 下界 视界 object Test{ def main(args:Array[String]):Unit={ def mulBy(factor:Double)=(x:Double)=>fa ...

  3. LoadRunner参数化功能详解

    更新方式: .      Each Occurrence 每次遇到参数就进行更新. 多次使用同一参数,而且没有什么关联,例如随机数. Each Iteration 每次迭代时发生更新. 如果参数出现几 ...

  4. [POJ] 1511 Invitation Cards

    Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 18198   Accepted: 596 ...

  5. mysql order by 妙用

    今天在做一个2次开发的时候,出现一个需求, 需要在商品分类页里面带一个参数,也就是商品ID, 如果分类链接里面有这个ID的时候就需要把这个商品排在分类商品列表的第1个, 原来的思路是,选择分类后,在P ...

  6. Unity3D TouchScript 插件教程一

    只是个人学习小记,谈不上教程,但是为了命中搜索引擎关键词,只好装逼了:),可能对于大家来说太简单了吧,网上中文教程没搜到 ,只好自己摸索了. 插件资源下载地址:https://www.assetsto ...

  7. ElasticSearch大批量数据入库

    最近着手处理大批量数据的任务. 现状是这样的,一个数据采集程序承载大批量数据的存储和检索.后期可能需要对大批量数据进行统计. 数据分布情况 13个点定时生成采集结果到4个文件(小文件生成周期是5分钟) ...

  8. Sql Server 2005的1433端口打开和进行远程连接

    参考地址:http://topic.csdn.net/u/20090828/16/e693935a-99b7-4090-a6bc-0123c91183eb.html 1.如何打开sql server  ...

  9. JQuery轻量级网页编辑器 选中即可编辑

    目前流行的可视化网页编辑器非常多,像ckeditor.kindeditor.tinyeditor等,虽然功能都非常强大,但是体积都比 较庞大,使用起来也不是很方便.今天我们分享一款基于jQuery的轻 ...

  10. Linux下如何选择文件系统:EXT4、Btrfs 和 XFS

    老实说,人们最不曾思考的问题之一是他们的个人电脑中使用了什么文件系统.Windows 和 Mac OS X 用户更没有理由去考虑,因为对于他们的操作系统,只有一种选择,那就是 NTFS 和 HFS+. ...