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


Author: ZHANG, Zheng

Source: Zhejiang Provincial Programming Contest 2005

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <functional>
#include <bitset>
#include <string> using namespace std; #define LL long long
#define INF 0x3f3f3f3f int a[30];
char ch[105]; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%s",ch);
int len=strlen(ch);
memset(a,0,sizeof a);
int sum=1;
char s=ch[0];
for(int i=1;i<len;i++)
{
if(ch[i]==s) sum++;
else
{
if(sum==1) printf("%c",s);
else printf("%d%c",sum,s);
sum=1;s=ch[i];
}
}
if(sum==1) printf("%c",s);
else printf("%d%c",sum,s);
printf("\n");
}
return 0;
}

ZOJ2478 Encoding 2017-04-18 23:02 43人阅读 评论(0) 收藏的更多相关文章

  1. Hdu 1009 FatMouse' Trade 2016-05-05 23:02 86人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  2. PAT甲 1009. Product of Polynomials (25) 2016-09-09 23:02 96人阅读 评论(0) 收藏

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  3. POJ3281 Dining 2017-02-11 23:02 44人阅读 评论(0) 收藏

    Dining Description Cows are such finicky eaters. Each cow has a preference for certain foods and dri ...

  4. ImageView一例 分类: H1_ANDROID 2013-10-30 23:02 1812人阅读 评论(0) 收藏

    参考自<疯狂android讲义>2.4节 效果如下: 当点击图上某点时,将之附近放大至下图. 布局文件: <LinearLayout xmlns:android="http ...

  5. POJ3273 Monthly Expense 2017-05-11 18:02 30人阅读 评论(0) 收藏

    Monthly Expense Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25959   Accepted: 10021 ...

  6. Hdu2204 Eddy's爱好 2017-06-27 16:11 43人阅读 评论(0) 收藏

    Eddy's爱好 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Subm ...

  7. Hadoop常见异常及其解决方案 分类: A1_HADOOP 2014-07-09 15:02 4187人阅读 评论(0) 收藏

    1.Shell$ExitCodeException 现象:运行hadoop job时出现如下异常: 14/07/09 14:42:50 INFO mapreduce.Job: Task Id : at ...

  8. NYOJ-235 zb的生日 AC 分类: NYOJ 2013-12-30 23:10 183人阅读 评论(0) 收藏

    DFS算法: #include<stdio.h> #include<math.h> void find(int k,int w); int num[23]={0}; int m ...

  9. HDU2033 人见人爱A+B 分类: ACM 2015-06-21 23:05 13人阅读 评论(0) 收藏

    人见人爱A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

随机推荐

  1. 类的"魔法"方法

    1. __init__()方法 <1>使用方式 def 类名: #初始化函数,用来完成一些默认的设定 def __init__(): pass 总结1 当创建Car对象后,在没有调用__i ...

  2. html资源 链接

    http://m.aicai.com/index.do?agentId=1&vt=5

  3. 【Java】JVM(一)、Java内存区域

    一.程序计数器(Program Counter Register) 当前执行字节码的行号指示器,可以通过修改该计数器的值来实现字节码指令(分支,循环,跳转等), 每个线程都都有一个程序计数器, 属于线 ...

  4. 命名空间出错 namespace Web.Skin.@default

    namespace Web.Skin.default会报错 因为default是关键字/保留字,所以需要在前面加@符号; namespace Web.Skin.@default

  5. repeater嵌套RadioButtonList赋值

    <asp:Repeater ID="Repeater1" runat="server"         onitemdatabound="Rep ...

  6. node.js压缩版 Windows安装

    1.下载 下载地址:https://nodejs.org/zh-cn/download/ 选择相应的版本下载 2.解压缩 将文件解压到要安装的位置,并新建两个目录 node-global :npm全局 ...

  7. Debian 采用 iso 镜像作为 apt 源

    1.将N个debian-506-amd64-DVD-N.iso存放于本地或其他媒介内,本例是放在本机/iso/目录下2.创建N个挂载点目录 如下: debian:~#mkdir –r /media/d ...

  8. laravel-excel文档翻译笔记

    1.安装      1>composer 安装 "maatwebsite/excel": "~2.1.0"      2>app/config/ap ...

  9. Netty 源码(一)服务端启动

    Netty 源码(一)服务端启动 Netty 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) ServerBootstap 创建时序图如 ...

  10. 图片素材类Web原型制作分享-Pexels

    Pexels是一个高清图片下载服务站点,为用户提供海量共享图片素材的网站,每周都会定量更新. 菜单栏和底部栏都是悬浮在固定位置,内容区域滚动.首页图片排列采用瀑布流的方式,多图片滚动.包含的页面有:浏 ...