hdu 1020
//自信满满地交上去~~but。。。超时了
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std; int main()
{
char ch[],c;
int i,k,j;
cin>>i;
while(i)
{
cin>>ch;
for(k=;k<strlen(ch);)
{
if(ch[k]!=ch[k+])
{cout<<ch[k];k++;}
else
{
c=ch[k];
for(j=k;ch[k]&&ch[j]==c;j++);
cout<<j-k<<c;
k=j;
}
}
cout<<endl;
i--;
}
return ;
}
//于是。。。重来。。。orz
//这是借鉴大神的。。。。发现自己的思路好单一。。。。。
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main()
{
int n,i,cnt;
char str[];
cin >> n;
while(n--)
{
cin >> str;
for(i = ; str[i]!='\0';)
{
cnt = ;
while(str[i] == str[i+])
{
cnt++;
i++;
}
if(cnt == )
cout << str[i];
else
cout << cnt << str[i];
i++;
}
cout << endl;
} return ;
}
hdu 1020的更多相关文章
- HDU 1020:Encoding
pid=1020">Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- hdu 1020 Encoding
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description Given a ...
- 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(连续同字符统计 **)
题意是要统计在一段字符串中连续相同的字符,不用再排序,相等但不连续的字符要分开输出,不用合在一起,之前用了桶排序的方法一直 wa,想复杂了. 代码如下: #include <bits/stdc+ ...
- 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【连续的计数器重置】
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)
并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
随机推荐
- jquery学习笔记2——jq效果
一.显示隐藏: 可以使用show()和hide()方法来显示隐藏: $("#hide").click(function(){ $("p").hide(); }) ...
- Tsung测试统计报告说明
Tsung测试统计报告说明 ********************** report.html *********************** 1.主要统计信息 Tsung统计数据是平均每十秒重 ...
- List之根据某个字段在add的时候过滤掉重复的数据
下面是重写ArrayList,并保证ChooseCars里面alpha字段不重复的例子 public class DistinctList extends ArrayList<ChooseCar ...
- hdu 1217 Arbitrage
Flody多源最短路 #include<cstdio> #include<cstring> #include<string> #include<cmath&g ...
- Chapter 2 Open Book——30
I looked down. His hands were clenched into hard fists again. 我向下看,他的双手又一次收紧握成拳头. Mr. Banner came to ...
- 字符串匹配—KMP 扩展KMP Manacher
kuangbin字符串专题传送门--http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70325#overview 算法模板: KMP: ; ...
- 在Wamp 添加站点和域名
在httpd.conf中使Include conf/extra/httpd-vhosts.conf生效 在conf/extra/httpd-vhosts.conf中加入如下代码 <Virtual ...
- Java 工具 JUnit单元测试
Java 工具 JUnit单元测试 @author ixenos 1.1. JUnit单元测试框架的基本使用 一.搭建环境: 导入junit.jar包(junit4) 二.写测试类: 0,一般一个 ...
- ubuntu 操作系统相关操作
查看操作系统位数 命令: getconf LONG_BIT root@hbg:/# getconf LONG_BIT 64 查看操作系统信息 命令: lsb_release -a root@hbg: ...
- c++的输入和输出流
C++编译系统提供了用于输入输出的iostream类库.iostream这个单词是由3个部 分组成的,即i-o-stream,意为输入输出流.在iostream类库中包含许多用于输入输出的 类.常用的 ...