HDU 1020:Encoding
pid=1020">Encoding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 25691 Accepted Submission(s): 11289
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.
2
ABC
ABBCCC
ABC
A2B3C
简单的水题。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream> using namespace std; const int M = 10000 + 50;
char str[M];
char a[M];
int b[M]; int main()
{
int n;
int t=0;
int p;
int i;
scanf("%d", &n);
while( n-- )
{
t=0;
p=0;
memset(str, 0, sizeof(str));
scanf("%s", str);
a[t]=str[0];
for(i=0; i<strlen(str); i++)
{
if(str[i]==str[i+1])
p++;
else
{
b[t]=p;
t++;
a[t]=str[i+1];
p=0;
}
}
for(i=0; i<t; i++)
{
if(b[i]>0)
printf("%d%c", b[i]+1, a[i]);
else
printf("%c", a[i]);
} printf("\n");
} return 0;
}
HDU 1020:Encoding的更多相关文章
- HDU - 6409:没有兄弟的舞会(数学+思维)
链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答 ...
- POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...
- HDU 1020 Encoding POJ 3438 Look and Say
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- HDU - 6397:Character Encoding (组合数&容斥)
题意:T组数据,给次给出N,M,K,多少种方案,用[0,N-1]范围的数,表示一个M排列,其和为K: 思路:隔板法,不限制[0,N-1]的时候答案是C(M+K-1,M-1):那么我们减去至少一个> ...
- HDU 1020 Encoding 模拟
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- HDU 1020 Encoding【连续的计数器重置】
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- hdu 1020 Encoding
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description Given a ...
- HDU 2732:Leapin' Lizards(最大流)
http://acm.hdu.edu.cn/showproblem.php?pid=2732 题意:给出两个地图,蜥蜴从一个柱子跳跃到另外一个地方,那么这个柱子就可能会坍塌,第一个地图是柱子可以容忍跳 ...
- HDU 4289:Control(最小割)
http://acm.hdu.edu.cn/showproblem.php?pid=4289 题意:有n个城市,m条无向边,小偷要从s点开始逃到d点,在每个城市安放监控的花费是sa[i],问最小花费可 ...
随机推荐
- javascript常用字符串函数和本地存储
concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a.conca ...
- js判断字符串str是否包含字符串substr
js判断字符串str是否包含字符串substr: function addUser(id,realName){ var userids = $("#userids").val(); ...
- ui-router路由控制器(一)
angularUI 在不断发展过程中已经被划分成了几个模块,你可以选择你需要的模块载入,我们今天要了解一下路由控制器 ui-router ,它就是angularUI划分出出来的一个独立模块. 此模块只 ...
- 【转】获取scrollTop兼容各浏览器的方法,以及body和documentElement是啥?
1.各浏览器下 scrollTop的差异 IE6/7/8: 对于没有doctype声明的页面里可以使用 document.body.scrollTop 来获取 scrollTop高度 : 对于有do ...
- [sh]shell命令缩写
命令缩写: ls:list(列出目录内容) cd:Change Directory(改变目录) su:switch user 切换用户 rpm:redhat package manager 红帽子打包 ...
- [na]思科产品选型pdf
以前做工程时候想起了设备选型时候用过的一份文档. 有个小伙伴今天问起思科设备选型,恰好google到了这份文档 https://www.cisco.com/web/CN/products/pdf/04 ...
- WCF transport-and-message-security
Things to Consider When Implementing a Load Balancer with WCF https://msdn.microsoft.com/library/hh2 ...
- application , application pool., W3wp ,httpapplication, domain
Hosting and Consuming WCF Services https://msdn.microsoft.com/en-us/library/bb332338.aspx http://www ...
- Mvc4 Layout布局与页面SEO信息title,keyword,description
工作已经五个年头了,在进入工作岗位时最初在.net 2.0平台一直到现在的.net 4.0平台下,开发了不少的winform.webform项目:五年的工作时间,在公司主持开发和维护了不少的电子商务w ...
- 每日英语:China's New Anti-Graft Website: A Tale of Tigers, Flies and Bath Tubs
With considerable fanfare, China's anti-graft squad has rolled out a brand new website in the ongoin ...