HDU 1020 Encoding 模拟
Encoding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 39047 Accepted Submission(s): 17279
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<stdio.h>
#include<string.h>
#include<queue>
#include<vector>
using namespace std;
struct Node
{
char a;
int num;
};
vector<Node> q; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
q.clear();
char ch[];
scanf("%s",ch);
int len=strlen(ch);
Node tmp;
tmp.a=ch[];
tmp.num=;
for(int i=;i<len;i++)
{
if(ch[i]==tmp.a) tmp.num++;
else
{
q.push_back(tmp);
tmp.a=ch[i];
tmp.num=;
}
}
q.push_back(tmp);
for(int i=;i<q.size();i++)
{
if(q[i].num>)
{
printf("%d%c",q[i].num,q[i].a);
}
else printf("%c",q[i].a);
}
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
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 4121 Xiangqi 模拟题
Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...
- hdu 5071 Chat(模拟)
题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...
- hdu 4740【模拟+深搜】.cpp
题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...
- HDU 2568[前进]模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2568 关键思想:傻傻地模拟 代码如下: #include<iostream> using ...
- hdu 4964 恶心模拟
http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...
随机推荐
- Python 面试中 8 个必考问题(转载)
Python 面试中 8 个必考问题 1.下面这段代码的输出结果是什么?请解释. def extendList(val, list=[]): list.append(val) return list ...
- Spring框架学习(1)Spring简介
内容源自:Spring 框架简介 Spring 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构允许您选择使用哪一个组件,同时为 J2EE 应用程序 ...
- linux中backticks反引号的作用
This is a backtick. A backtick is not a quotation sign. It has a very special meaning. Everything yo ...
- web页面实时更新页面的原理--WebSocket
原文:https://www.jianshu.com/p/8f956cd4d42b angular-cli启动的项目也可以自动刷新,底下应该也是应用的websocket的原理. ----------- ...
- Mac OS X 10.10 执行 Eclipse 提示须要安装 Java
- Notepad++的使用
\t 制表符. \n 新行. . 匹配任意字符. | 匹配表达式左边和右边的字符. 例如, "ab|bc" 匹配 "ab" 或者 "bc&quo ...
- Moving Tables-贪心
id=19566" target="_blank" style="color:blue; text-decoration:none">Movin ...
- ffmpeg代码解析
void avdevice_register_all(void){ static int initialized; if (initialized) return; i ...
- Unity3D性能优化小tips——把this.transform缓存缓存起来
Unity3D开发时中有一个小tips,这在官方的文档里其实有提及的,但不那么显眼,这里小说一下: 在MonoBehaviour进行编程时,我们经常会用this.transform, this.gam ...
- Ubuntu12.04 Bugzilla 和 TestOpia的安装步骤
1. 安装apache User@ubuntu:$ sudo apt-get install apache2 注:安装完以后能够通过http://192.168.128.128/ 来訪 ...