HDOJ 1012 Encoding
来源:互联网 发布:淘宝微商 编辑:程序博客网 时间:2024/06/05 20:20
Encoding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18725 Accepted Submission(s): 8068
Problem Description
Given a string containing only 'A' - 'Z', we could encode it using the following method:
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.
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.
Input
The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 10000.
Output
For each test case, output the encoded string in a line.
Sample Input
2ABCABBCCC
Sample Output
ABCA2B3C
Author
ZHANG Zheng
Recommend
JGShining
纯水题,不解释。。。NOIP2007提高组第二题比这个麻烦多了
#include <iostream>using namespace std;int main(int argc, char *argv[]){string s; int ii,n;cin>>n;for (int i=0;i<n;++i){cin>>s; for (int j=0;j<s.length();++j){ii=1;while ((s[j+1]==s[j])&&(j<s.length()-1)){++j; ++ii;}if (ii>1) cout<<ii;cout<<s[j];}cout<<endl;}return 0;}
kdwycz的网站: http://kdwycz.com/
kdwyz的刷题空间:http://blog.csdn.net/kdwycz
- HDOJ 1012 Encoding
- HDOJ Encoding
- HDOJ Encoding
- HDOJ 1020 Encoding
- hdoj 1020 Encoding
- hdoj 1020 Encoding
- HDOJ 1020 ENcoding
- hdoj 1020 encoding
- HDOJ 1020 Encoding
- HDOJ 1020 Encoding
- HDOJ 1020 Encoding
- hdoj-1020-Encoding
- HDOJ 1020 Encoding
- [HDOJ 1020]Encoding 字符串编码
- [HDOJ 1020]Encoding 字符串编码
- hdoj 1020 Encoding (水题)
- ACM--字母序列--HDOJ 1020--Encoding--字符串
- Encoding
- android相对布局 相对对齐
- poj 1118 最多共线的点
- CakePHP运行报错The requested URL XX was not found on this server.
- 继承和组合
- C语言学习之 scanf
- HDOJ 1012 Encoding
- css兼容IE6/IE7/FF的通用方法和著名的Clearfix Hack
- ActiveXObject
- 重启ORACLE
- 互联网基本架构
- 连接到oracle10g,过段时间后自动断开,报ORA-03135错误
- quartz的触发器CronTriggerBean 配置
- startservice和bindservice的区别
- 看完这个你的位运算学得就差不多了