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<cstdio>
#include<cstring>
int main()
{
int N;
int a[];
int v;
int temp=;
scanf("%d",&N);
getchar();
while(N--)
{
memset(a,,sizeof(a));
v=getchar();
temp=v;
while(temp!='\n')
{ if(v!=temp)
{
if(a[temp]>) printf("%d%c",a[temp],temp);
if(a[temp]==) printf("%c",temp);
a[temp]=;
a[v]++;
}
else a[v]++;
temp=v;
if(v!='\n') v=getchar();
}
printf("\n");
}
}
/*题意没看清,wa了几次,题目说了是子序列,那么对于例子 AABBBCCCAABB 应输出2A3B3C2A2B*/

Encoding的更多相关文章

  1. javac -encoding utf8 in linux

    由于另外负责编码的同事用的是utf-8,我用的默认的编码格式gbk,在提交代码时,为了迁就他,我打算把格式用工具转成utf-8. 转化成果后,然后在make一下,发现javac -encoding u ...

  2. 创建Odoo8数据库时的“new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)“问题

    Odoo8创建数据库时,显示如下错误信息: DataError: new encoding (UTF8) is incompatible with the encoding of the templa ...

  3. Node.js Base64 Encoding和Decoding

    如何在Node.js中encode一个字符串呢?是否也像在PHP中使用base64_encode()一样简单? 在Node.js中有许多encoding字符串的方法,而不用像在JavaScript中那 ...

  4. java Properties异常:Malformed \uxxxx encoding.

    昨天项目中遇到一个 java.lang.IllegalArgumentException: Malformed \uxxxx encoding.这样的一个异常,debug了一下发现是读取propert ...

  5. svn: Can't convert string from 'UTF-8' to native encoding 的解决办法(转)

    http://www.cnblogs.com/xuxm2007/archive/2010/10/26/1861223.html svn 版本库中有文件是以中文字符命名的,在 Linux 下 check ...

  6. C# 字符编码类Encoding

    在网络通信中,很多情况下都是将字符信息转成字节序列进行传输.将字符序列转为字节序列的过程称为编码.当这些字节传送到接收方,接收方需要逆向将字节序列转为字符序列.这个过程就是解码. 常见编码有ASCII ...

  7. 字符集和字符编码(Charset & Encoding)

    字符集和字符编码(Charset & Encoding)[转] 1.基础知识 计算机中储存的信息都是用二进制数表示的:而我们在屏幕上看到的英文.汉字等字符是二进制数转换之后的结果.通俗的说,按 ...

  8. 使用英文版eclipse保存代码,出现some characters cannot be mapped using "Cp1251" character encoding.

    some characters cannot be mapped using "Cp1251" character encoding. 解决办法:方案一: eclipse-> ...

  9. <?xml version="1.0" encoding="UTF-8"?> 的作用?

    version="1.0" 声明用的xml版本是1.0 encoding="UTF-8" 声明用xml传输数据的时候的字符编码,假如文档里面有中文,编码方式不是 ...

  10. 关于Unicode和URL encoding入门的一切以及注意事项

    本文同时也发表在我另一篇独立博客 <关于Unicode和URL encoding入门的一切以及注意事项>(管理员请注意!这两个都是我自己的原创博客!不要踢出首页!不是转载!已经误会三次了! ...

随机推荐

  1. Altera的几个常用的Synthesis attributes

    各厂商综合工具,对HDL综合时都定义了一些综合属性这些属性可指定a declaration,a module item,a statement, or a port connection 不同的综合方 ...

  2. Todd's Matlab讲义第1讲:向量,函数和作图

    向量 Matlab 中最基本的对象是矩阵,向量是特殊的矩阵.行向量是\(1\times n\)矩阵,列向量是\(m\times 1\)矩阵.输入如下行向量: >> v=[0 1 2 3] ...

  3. js 判断所有节假日

    // JavaScript Document calendar = new Date(); month = calendar.getMonth(); date = calendar.getDate() ...

  4. hiho一下 第九十七周 数论六·模线性方程组

    题目1 : 数论六·模线性方程组 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:今天我听到一个挺有意思的故事! 小Hi:什么故事啊? 小Ho:说秦末,刘邦的将军 ...

  5. hiho一下 第九十四周 数论三·约瑟夫问题

    数论三·约瑟夫问题 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho的班级正在进行班长的选举,他们决定通过一种特殊的方式来选择班长. 首先N个候选人围成一个 ...

  6. OpenCV入门(二)

    这次主要学习了下滤波,就当复习了图像处理的知识了:http://blog.csdn.net/poem_qianmo/article/details/22745559 代码实现比较简单,但关于通过滚动条 ...

  7. linux zookeeper 原理详解

    http://cailin.iteye.com/blog/2014486  直接打开此链接即可 --------------------------------------------------   ...

  8. dhcp原理、安装、相关命令、疑惑

    转自: http://blog.sina.com.cn/s/blog_642e41c20101tct3.html

  9. Unique Paths | & ||

    Unique Paths I A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diag ...

  10. 用几条shell命令快速去重10G数据

    试想一下,如果有10G数据,或者更多:怎么才能够快速地去重呢?你会说将数据导入到数据库(mysql等)进行去重,或者用java写个程序进行去重,或者用Hadoop进行处理.如果是大量的数据要写入数据库 ...