HDU 1020.Encoding-字符压缩
Encoding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 55351 Accepted Submission(s): 24697
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<stdio.h>
#include<string.h>
int main(){
char str[];
int n,i,cnt;
while(~scanf("%d",&n)){
while(n--){
scanf("%s",&str);
for(i=;str[i]!='\0';i++){
cnt=;
while(str[i]==str[i+]){
cnt++;i++;
}
if(cnt==) printf("%c",str[i]);
else printf("%d%c",cnt,str[i]);
}
printf("\n");
}
}
return ;
}
HDU 1020.Encoding-字符压缩的更多相关文章
- 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 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 1020:Encoding
pid=1020">Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- hdu 5094 Maze 状态压缩dp+广搜
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092176.html 题目链接:hdu 5094 Maze 状态压缩dp+广搜 使用广度优先 ...
- hdu 5724 SG+状态压缩
Chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
- HDU 1020(连续同字符统计 **)
题意是要统计在一段字符串中连续相同的字符,不用再排序,相等但不连续的字符要分开输出,不用合在一起,之前用了桶排序的方法一直 wa,想复杂了. 代码如下: #include <bits/stdc+ ...
- hdu 4272 LianLianKan 状态压缩
LianLianKan Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
随机推荐
- 【python】python 中的三元表达式(三目运算符)
python中的三目运算符不像其他语言其他的一般都是 判定条件?为真时的结果:为假时的结果 如 result=5>3?1:0 这个输出1,但没有什么意义,仅仅是一个例子.而在python中的格式 ...
- BZOJ4347 POI2016Nim z utrudnieniem(博弈+动态规划)
由nim游戏的结论,显然等价于去掉一些数使剩下的数异或和为0. 暴力的dp比较显然,设f[i][j][k]为前i堆移走j堆(模意义下)后异或和为k的方案数.注意到总石子数量不超过1e7,按ai从小到大 ...
- powershell入门教程-v0.3版
powershell入门教程-v0.3版 来源 https://www.itsvse.com/thread-3650-1-1.html 参考 http://www.cnblogs.com/piapia ...
- [洛谷P4124][CQOI2016]手机号码
题目大意:给你两个$l,r$,求出$[l,r]$中符合要求的数,要求为至少有$3$个相邻的相同数字,且不可以同时出现$8$和$4$ 题解:数位$DP$ 卡点:无 C++ Code: #include ...
- 原生toolbar基本使用教程
1.先写布局文件 <android.support.v7.widget.Toolbar android:id="@+id/toolbar" app:title=" ...
- poj1185 炮兵阵地 状压dp
司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队.一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示) ...
- bzoj 4004 [JLOI2015]装备购买 拟阵+线性基
[JLOI2015]装备购买 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 1820 Solved: 547[Submit][Status][Dis ...
- HDU1025---(LIS 最长上升子序列 的应用)
分析: n行 每行包含两个整数p r;意思是p从到r 不能有交叉的路 p刚好从1->n, 可看做下标,到的地方看做值 就转化为了最长上升子序列的问题 此题难点,怎么将其转化为LIS问题 #inc ...
- Python基础(2)_if、for、while流程控制
一.流程控制 1.条件语句 1.1单分支 1.2多分支 条件判断 计算机之所以能做很多自动化的任务,因为它可以自己做条件判断. a = 5 if a > 2: print('yes') 根据Py ...
- 【HDU5785】Interesting [Manacher]
Interesting Time Limit: 30 Sec Memory Limit: 256 MB[Submit][Status][Discuss] Description Input Outp ...