Encoding


Time Limit: 2 Seconds      Memory Limit: 65536 KB

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 100.

Output

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

Sample Input

2
ABC
ABBCCC

Sample Output

ABC
A2B3C

 #include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s;
cin >> n;
while(n--){
cin >> s;
int len = s.length();
int num = ;
if(len == ){
cout << s << endl;
continue;
}
for(int i = ; i < len - ; i++){
if(s[i] == s[i + ]){
num++;
} else {
if(num == )
cout << s[i];
else
cout << num << s[i] ;
num = ;
}
}
if(s[len - ] == s[len - ])
cout << num << s[len - ];
else
cout << s[len - ];
cout << endl;
}
// system("pause");
return ;
}

ZOJ 2478 Encoding的更多相关文章

  1. ZOJ 3494 BCD Code(AC自动机+数位DP)

    BCD Code Time Limit: 5 Seconds      Memory Limit: 65536 KB Binary-coded decimal (BCD) is an encoding ...

  2. ZOJ 3430 Detect the Virus

    传送门: Detect the Virus                                                                                ...

  3. ZOJ 4114 Detect the Virus(AC自动机)

    Detect the Virus Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Nobita found that his co ...

  4. ZOJ - 3430 Detect the Virus —— AC自动机、解码

    题目链接:https://vjudge.net/problem/ZOJ-3430 Detect the Virus Time Limit: 2 Seconds      Memory Limit: 6 ...

  5. Detect the Virus ZOJ - 3430 AC自动机

    One day, Nobita found that his computer is extremely slow. After several hours' work, he finally fou ...

  6. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  7. javac -encoding utf8 in linux

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

  8. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  9. 创建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 ...

随机推荐

  1. apache mod_alias模块功能介绍

    我觉得mod_alias根mod_rewrite挺像的,都可以实现url的重写,而mod_alias可以实现简单的url重写的功能 ,而mod_rewrite可以实现比较复杂的重写.mod_alias ...

  2. 进度条--ProgressBar和BackgroundWorker

    1) 需求:就餐打卡数据处理后,插入数据库中,用进度条显示过程 2) 思路:总进度为txt文本文件的行数(数据都是按照行写入),文本文件的大小 //BackgroundWorker对象有三个主要的事件 ...

  3. CF963A Alternating Sum

    思路:利用周期性转化为等比数列求和. 注意当a != b的时候 bk * inv(ak) % (109 + 9)依然有可能等于1,不知道为什么. 实现: #include <bits/stdc+ ...

  4. 一键修改android 字体和图片大小.

    项目中需要动态更改 app的字体和图片, 在查阅中找到的更改主题的解决办法,和单独的修改字体的方法.  这两种方法的确有效果但是实现麻烦,在修改字体的过程中,找到一个额外的方法,  修改字体的实现更改 ...

  5. 【HEVC帧间预测论文】P1.9 Coding Tree Depth Estimation for Complexity Reduction of HEVC

    Coding Tree Depth Estimation for Complexity Reduction of HEVC <HEVC标准介绍.HEVC帧间预测论文笔记>系列博客,目录见: ...

  6. PHP环境搭建Zend Studio 10.6.2+WampServer2.4

    址:http://www.zend.com/en/products/studio/downloads直接下载地址:http://downloads.zend.com/studio-eclipse/10 ...

  7. ListView中含有EditText时候--要命的焦点问题迎刃而解

    最近做项目的时候遇到了一个问题,就是在ListView的item上面含有一个EditText,要求是这样: 1当点击item的时候,item可以点击; 2当点击EditText的时候EditText也 ...

  8. b继承a的函数

    var cls={ my:, init:function() { alert(this.my.a); }};window.onload=function(){ cls.init();} 调用cls.i ...

  9. js 数组元素排序?

    Part.1  sort 方法 js 有自带排序方法 sort(),  默认 升序 排列 如: data() { return { arr: [1,3,2,5,6,8,7,4,9] } }, 控制台如 ...

  10. DFS || HDU 2181

    题意:一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市. 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每 ...