POJ 3438:Look and Say
| Time Limit: 5000MS | Memory Limit: 65536K | |
| Total Submissions: 9196 | Accepted: 5566 |
Description
can be described as "one 1, two 2's, one 3, two 4's, three 1's". Therefore, the element that comes after 122344111 in the sequence is 1122132431. Similarly, the string 101 comes after 1111111111. Notice that it is generally not possible to uniquely identify
the previous element of a particular element. For example, a string of 112213243 1's also yields 1122132431 as the next element.
Input
Output
Sample Input
3
122344111
1111111111
12345
Sample Output
1122132431
101
1112131415
洪水题,看着读这个数,再输出。
代码:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; string s; void solve()
{
int i,j;
int len=s.length(); for(i=0;i<len;i++)
{
int result=1;
for(j=i+1;j<len;j++)
{
if(s[j]==s[i])
{
result++;
}
else
{
break;
}
}
cout<<result<<s[i];
i=i+result-1;
}
cout<<endl;
} int main()
{
int Test;
cin>>Test; while(Test--)
{
cin>>s;
solve();
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 3438:Look and Say的更多相关文章
- POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...
- POJ 3252:Round Numbers
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...
- POJ 1459:Power Network(最大流)
http://poj.org/problem?id=1459 题意:有np个发电站,nc个消费者,m条边,边有容量限制,发电站有产能上限,消费者有需求上限问最大流量. 思路:S和发电站相连,边权是产能 ...
- POJ 3436:ACM Computer Factory(最大流记录路径)
http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2* ...
- POJ 2195:Going Home(最小费用最大流)
http://poj.org/problem?id=2195 题意:有一个地图里面有N个人和N个家,每走一格的花费是1,问让这N个人分别到这N个家的最小花费是多少. 思路:通过这个题目学了最小费用最大 ...
- POJ 3281:Dining(最大流)
http://poj.org/problem?id=3281 题意:有n头牛,f种食物,d种饮料,每头牛有fnum种喜欢的食物,dnum种喜欢的饮料,每种食物如果给一头牛吃了,那么另一个牛就不能吃这种 ...
- POJ 3580:SuperMemo(Splay)
http://poj.org/problem?id=3580 题意:有6种操作,其中有两种之前没做过,就是Revolve操作和Min操作.Revolve一开始想着一个一个删一个一个插,觉得太暴力了,后 ...
- POJ 3237:Tree(树链剖分)
http://poj.org/problem?id=3237 题意:树链剖分.操作有三种:改变一条边的边权,将 a 到 b 的每条边的边权都翻转(即 w[i] = -w[i]),询问 a 到 b 的最 ...
- POJ 2763:Housewife Wind(树链剖分)
http://poj.org/problem?id=2763 题意:给出 n 个点, n-1 条带权边, 询问是询问 s 到 v 的权值, 修改是修改存储时候的第 i 条边的权值. 思路:树链剖分之修 ...
随机推荐
- kubernetes集群全栈监控报警方案kube-prometheus
参考文档 http://www.servicemesher.com/blog/prometheus-operator-manual/ https://github.com/coreos/prometh ...
- KAZE特征和各向异性扩散滤波
kaze feature: http://www.doc88.com/p-6911376909693.html 各向异性扩散滤波 Scale-space and edge detection usi ...
- Spring组件扫描--源码跟踪
看这篇文章之前可以先了解之前的跟踪流程,https://www.jianshu.com/p/4934233f0ead 代码过宽,可以shift + 鼠标滚轮 左右滑动查看 这篇文章主要跟踪spring ...
- cenos7配置confluence+mysql5.6
一.准备阶段 我的环境为 腾讯云镜像centos7.4 ,centos 内置 mariadb 需要先删除 #检查是否安装了 mariadb rpm -qa |grep mariadb #删除mari ...
- espcms P8.19082801 vulnerability
author: naiquan chai Net name:Hanamizuki花水木 Through the vulnerability we can get the webshell if w ...
- 《机学一》特征工程1 ——文本处理:sklearn抽取、jieba中文分词、TF和IDF抽取
零.机器学习整个实现过程: 一.机器学习数据组成 特征值: 目标值: 二.特征工程和文本特征提取 1.概要: 1.特征工程是什么 2.特征工程的意义:直接影响预测结果 3.scikit-learn库 ...
- mybatis插入数据后将其ID返回
背景 mybatis没有关联保存的功能,所以主从表需要分开保存,这就涉及到主表保存后要再次获取主表ID的环节,以下介绍mybatis插入数据后返回其自增ID的两种方式 方案 1.sql获取 <i ...
- POJ 3077 : Rounders
Rounders Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7827 Accepted: 5062 Description ...
- xargs详细
转自 http://czmmiao.iteye.com/blog/1949225 简介之所以能用到这个命令,关键是由于很多命令不支持|管道来传递参数,而日常工作中有有这个必要,所以就有了xargs命 ...
- ipv6_RIPng配置
ipv6 unicast-routing——类似IPv4的ip routing ipv6 route rip word——启用IPv6进程 防止环路——split-horizon——水平分割——不再接 ...