hdu1020Encoding
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.
ABC
ABBCCC
A2B3C
#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的更多相关文章
- HDU-1020-Encoding(水题,但题目意思容易搞错,英语的问题)
题目链接 http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1000&ojid=0&cid=7996&h ...
- HDU-1020-Encoding,题意不清,其实很水~~
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) http:// ...
随机推荐
- C#基本数据类型与C++区别
与C++不同的地方: char占两个字节存Unicode字符, long long 改为 long ; unsize ... 改为 u... 新增: byte占1个字节,类似与C++char, sby ...
- The Lead Game Add problem to Todo list Problem code: TLG
'''def count_lead(first, second): if first > second: return 1, first - second elif first == secon ...
- Compound class names are not supported. Consider searching for one class name and filtering the results
原文地址:http://stackoverflow.com/questions/20361643/compound-class-names-are-not-supported-consider-sea ...
- 记一次 java程序优化
优化原因 环境中部署两个程序: web应用 tomcat 10G(webservice服务端,前端web服务) java应用 5G(webservice客户端,sock ...
- 初识lucene
lucene的介绍网上有好多,再写一遍可能有点多余了. 使用lucene之前,有一系列的疑问 为什么lucene就比数据库快? 倒排索引是什么,他是怎么做到的 lucene的数据结构是什么样的,cpu ...
- HDU 1540 Tunnel Warfare (线段树)
题目大意: n 个村庄排列在一条直线上,相邻的村庄有地道连接,除首尾两个村庄外,其余村庄都有两个相邻的村庄.其中有 3 中操作 D x :表示摧毁编号为 x 的村庄,Q x:表示求出包含村庄 x 的最 ...
- exe可执行程序及堆栈分配(转载)
可执行程序的内存分布 GNU编译器生成的目标文件默认格式为elf(executive linked file)格式,这是Linux系统所采用的可执行链接文件的通用文件格式.elf格式由若干个段(sec ...
- UVa156.Ananagrams
题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 北京Uber优步司机奖励政策(12月3日)
用户组:人民优步(适用于12月3日) 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://w ...
- [转] Hive 内置函数
原文见:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF 1.内置运算符1.1关系运算符 运算符 类型 说明 A ...