HDU 1020 Encoding POJ 3438 Look and Say
Encoding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11132 Accepted Submission(s): 4673
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.
Output
Sample Input
#include<iostream>
using namespace std; int main(){
int t;
char str[];
scanf("%d",&t);
while(t--){
scanf("%s",str);
int count=;
for(int i=;i<strlen(str);i++){
if(str[i]==str[i+])count++;
else{
if(count==) printf("%c",str[i]);
else printf("%d%c",count,str[i]);
count=;
}
}
printf("\n");
}
}
Time Limit: 5000MS | Memory Limit: 65536K | |
Total Submissions: 9179 | Accepted: 5552 |
Description
Input
Output
Sample Input
3
122344111
1111111111
12345
Sample Output
1122132431
101
1112131415
Source
#include<iostream>
using namespace std; int main(){
int t;
char str[];
scanf("%d",&t);
while(t--){
scanf("%s",str);
int count=;
for(int i=;i<strlen(str);i++){
if(str[i]==str[i+])count++;
else{
printf("%d%c",count,str[i]);
count=;
}
}
printf("\n");
}
}
HDU 1020 Encoding POJ 3438 Look and Say的更多相关文章
- 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 1815, POJ 2749 Building roads(2-sat)
HDU 1815, POJ 2749 Building roads pid=1815" target="_blank" style="">题目链 ...
- HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP)
HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP) Description The French author George ...
- HDU 1816, POJ 2723 Get Luffy Out(2-sat)
HDU 1816, POJ 2723 Get Luffy Out pid=1816" target="_blank" style="">题目链接 ...
- hdu 1513 && 1159 poj Palindrome (dp, 滚动数组, LCS)
题目 以前做过的一道题, 今天又加了一种方法 整理了一下..... 题意:给出一个字符串,问要将这个字符串变成回文串要添加最少几个字符. 方法一: 将该字符串与其反转求一次LCS,然后所求就是n减去 ...
- hdu 1043 pku poj 1077 Eight (BFS + 康拓展开)
http://acm.hdu.edu.cn/showproblem.php?pid=1043 http://poj.org/problem?id=1077 Eight Time Limit: 1000 ...
随机推荐
- WPF实现窗体最小化后小图标在右边任务栏下
一 基本功能 1. 这里是用 NotifyIcon 控件来实现,但 WPF 下没有 NotifyIcon 控件,怎么办,用 WinForm 下的呗. 先引用 .NET 自带的两个程序集 Syste ...
- Properties的读取和写入
Properties是HashTable下的一个持久的属性集,没有泛型,key-value都是String类型.由于能与IO流结合使用,所以能方便地操作属性文件或者xml文件. 一.propertie ...
- sublimetext3官网安装
1. 下载 可以从官网 http://www.sublimetext.com/3 下载. 2. Windows下安装与使用2.1 安装 1. Win7 64位系统,可以下载 Windows 64 bi ...
- Unique Binary Search Trees In JAVA
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- Oracle sql语言模糊查询--like后面的通配符
关于like后面的条件,Oracle提供了四种匹配模式: 1,% :表示任意0个或多个字符.可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分号(%%)表示. 比如 SELECT * FR ...
- Redis与Scrapy
Redis与Scrapy Redis与Scrapy Redis is an open source, BSD licensed, advanced key-value cache and store. ...
- flask 后台表单验证模块
我不想直接用flask的wtf模块,太大,功能太多,用不了.但后台也不能不做验证吧,我比较懒,不想一行一行写代码验证,所以就写了一个验证模块,对于小项目也够用了 # encoding=utf-8 # ...
- Python Challenge 过关心得(0)
最近开始用Openerp进行开发,在python语言本身上并没有什么太大的进展,于是决定利用空闲时间做一点python练习. 最终找到了这款叫做Python Challenge(http://www. ...
- 整数v,从高位到低位,取c位数,得到最大数 (其中:v>=10^c)
题目如上,例子v=22312324,c=3,求得最大数为334. 用自己的想法实现了一遍,如果你有更好的方法的话,欢迎不吝赐教. 我的思路是,先将整数v按位存入一个数组,数组低位为整数高位,如num[ ...
- std::map的insert和下标[]访问
在map中插入元素 改变map中的条目非常简单,因为map类已经对[]操作符进行了重载 enumMap[1] = "One";enumMap[2] = "Two" ...