HDU
来源:互联网 发布:淘宝休闲斜挎包 编辑:程序博客网 时间:2024/06/06 07:11
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.
2ABCABBCCC
ABCA2B3C
#include<iostream>#include<cstdio>using namespace std;int main(){char ch;int T;cin >> T;getchar();while(T--){int f[1050] = {1}, index = 0;char c[1050];c[0] = getchar();char initial = c[0];while((ch = getchar()) != '\n'){if(initial == ch){++f[index];}else{++index;initial = ch;c[index] = ch;f[index] = 1;}}for(int i = 0; i <= index; ++i){if(f[i] > 1)cout << f[i];cout << c[i];}cout << endl;}}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- react之onChange事件
- 模拟实现STL-Vector
- Java HashMap的扩容
- HDFS的工作机制,HDFS写数据流程,HDFS读数据流程(来自学习资料)
- 27、移动端适配
- HDU
- 《深入理解Java虚拟机》
- 细说react-native中的SectionList
- [算法] 基本图算法:深度优先搜索、广度优先搜索
- 深度学习训练技巧(一)
- Handler源码解析
- java基本类型与包装类型区别
- 深度学习调参技巧(三)
- 从适应区到习惯,再到能力