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. 定义了重复的system.web.extensions/scripting/scriptResourceHandler怎么办

    今天移转系统,都配置好之后,系统报错说我的web服务下的web.config 定义了重复的 system.web.extensions/scripting/scriptResourceHandler ...

  2. hdu 素数环

    算法:搜索 题意:相邻的两个数之和是素数,别忘了最后一个,和第一个 Problem Description A ring is compose of n circles as shown in dia ...

  3. linux中的fork函数的基本用法

    代码: #include <iostream> #include <string> #include <cstdio> #include <unistd.h& ...

  4. git的安装已经连github

    https://help.github.com/articles/generating-ssh-keys 1.安装git [plain]  view plain copy   sudo apt-get ...

  5. jquery uploadify插件多文件上传

    1.jquery uploadify 下载:http://www.uploadify.com/ 2.安装:解压后拷贝的工程目录下面,如:WebRoot/uploaddify 3.配置项说明: uplo ...

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

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

  7. 开心菜鸟系列----变量的解读(javascript入门篇)

                       console.info(         console.info(window['weiwu'])          console.info(window. ...

  8. 网站10大致命SEO错误

    1.关键字堆砌 我想不出有比胡乱将这些复制的内容放在网站上更差劲的事情了.网站复制一遍又一遍,你肯定也不想看到这么差劲的网站复制. 你在明白我在做什么吗?我并不是一个那么差劲的编辑者,我只是想说明一个 ...

  9. Linux配置FTP服务器

    基于CentOS-6.5 1.先查看是否已安装:rpm -qa vsftpd 或 rpm -ql vsftpd 2.安装:yum install vsftpd -y 3.设置开机启动: chkconf ...

  10. poj 3669 Meteor Shower(bfs)

    Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteo ...