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 ...
随机推荐
- 百度搜索附近加盟店等基于LBS云搜索功能的实现
一.注册百度账号,进入开发者平台 创建应用并获取ak 地址如下 http://lbsyun.baidu.com/apiconsole/key/update?app-id=7546025 ok获取到了. ...
- android中跨进程通讯的4种方式
转自:http://blog.csdn.net/lyf_007217/article/details/8542359 帖子写的很好.看来一遍,试了一遍,感觉太有意义.必须转过来! android中跨进 ...
- 部署sharepointform验证
1 iis sharepoint v4 提供程序2 web service 验证提供程序3 创建web应用程序(选择基于身份验证模式,配置提供程序)4 创建网站集(空)5 创建网站集
- C#事件、委托简单示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 关于OC中的几种代码延迟执行方式
第一种: [UIView animateWithDuration:3 delay:3 options:1 animations:^{ self.btn.transform = CGAf ...
- C - Big Number
Description In many applications very large integers numbers are required. Some of these application ...
- 从汇编看c++中全局对象和全局变量
先来看c++源码: #include <iostream> using namespace std; class X { public: int i; public: X() : i(ii ...
- php 汉字排序
<?phpheader("content-type:text/html;charset=utf-8");$array=array('重庆市','上海市','安徽省','吉林省 ...
- python 2.6升级到2.7
CentOS 6.5上安装的python版本是2.6.6,不能满足我运行软件的要求,所以对python进行升级. 原以为这也就是安装个软件的事儿,在我求稳搜索一下了之后发现,也并不是那么单纯简单. 下 ...
- 修改Windows系统的启动Shell
前提:当前系统中有可用的shell文件 方法: 修改当前用户的系统默认shell(只对当前用户生效,且优先于本机默认的shell) 修改“HKCU\SOFTWARE\Microsoft\Windo ...