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. SpringMVC关于json、xml自动转换的原理研究

    SpringMVC是目前主流的Web MVC框架之一. 如果有同学对它不熟悉,那么请参考它的入门blog:http://www.cnblogs.com/fangjian0423/p/springMVC ...

  2. 初学require.js

    引入require.js,可以解决的问题: (1)实现js文件的异步加载,避免网页失去响应: (2)管理模板之间的依赖性,便于代码的编写和维护. 它的模块管理遵循AMD规范(Asynchronous ...

  3. 第15章 使用Postfix与Dovecot收发电子邮件

    章节概述: 本章节从电子邮局系统的组成角色开始讲起,了解MUA.MTA与MDA的作用,熟悉熟悉SMTP.POP3与IMAP4邮局协议. 学习postfix与dovecot服务程序的使用方法并逐条讲解配 ...

  4. [codeforces 509]C. Sums of Digits

    [codeforces 509]C. Sums of Digits 试题描述 Vasya had a strictly increasing sequence of positive integers ...

  5. System.SysUtils.TMarshaller 与 System.TMarshal

    转自:http://www.cnblogs.com/del/archive/2013/06/10/3130974.html TMarshaller(结构) 基于 TMarshal(是有一大堆的 cla ...

  6. failed to load session "ubuntu"

    https://answers.launchpad.net/ubuntu/+source/gnome-desktop/+question/211792

  7. 【云计算】基于Ansible的自动部署平台化思路

    目标: 1.自动化—支持命令行.webui.api调用 2.支持基础命令.脚本.复杂任务编排.满足生产环境各类模块自动化部署需求 3.满足生产环境(开发.测试.线上)性能.可靠性.安全性要求 4.流程 ...

  8. jQuery获取Select选择的Text和 Value(转)

    radio: radio: var item = $('input[name=items][checked]').val(); var item = $('input[name=items]:chec ...

  9. JSON: property "xxx" has no getter method in class "..."

    Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Pro ...

  10. UEditor去除复制样式实现无格式粘贴

    UEditor内置了无格式粘贴的功能,只需要简单的配置即可. 1.修改ueditor.config.js,开启retainOnlyLabelPasted,并设置为true 2.开启pasteplain ...