1140 Look-and-say Sequence
题意:略
思路:第1个数是1(读作“1有1个”),因此第2个数就是11(读作“1有2个”),因此第3个数就是12(读作“1有1个,2有1个”),因此第4个数是1121(读作“1有2个,2有1个,1有1个”),因此第5个数是122111......懂了吧。
代码:
#include <string>
#include <iostream>
using namespace std;
int main()
{
int d,n;
cin>>d>>n;
,d+');
;k<n;k++){
;
string temp;
while(i<str.size()){
int s=i;
char pre=str[s];
while(i<str.size() && str[i]==pre) i++;
int cnt=i-s;
temp+=,pre)+,cnt+');
}
str=temp;
}
cout<<str;
;
}
1140 Look-and-say Sequence的更多相关文章
- PAT 1140 Look-and-say Sequence
1140 Look-and-say Sequence (20 分) Look-and-say sequence is a sequence of integers as the following ...
- PAT 1140 Look-and-say Sequence [比较]
1140 Look-and-say Sequence (20 分) Look-and-say sequence is a sequence of integers as the following: ...
- [PAT] 1140 Look-and-say Sequence(20 分)
1140 Look-and-say Sequence(20 分)Look-and-say sequence is a sequence of integers as the following: D, ...
- 1140 Look-and-say Sequence (20 分)
Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213 ...
- PAT Advanced 1140 Look-and-say Sequence (20 分)
Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213 ...
- PAT甲级——1140.Look-and-say Sequence (20分)
Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213 ...
- PTA 1140 1141 1142 1143
1140 Look-and-say Sequence 思路:模拟 #include<bits/stdc++.h> using namespace std; typedef long lon ...
- PAT (Advanced Level) 1140~1143:1140模拟 1141模拟 1142暴力 1143 BST+LCA
1140 Look-and-say Sequence(20 分) 题意:观察序列D, D1, D111, D113, D11231, D112213111, ...,显然后一个串是对前一个串每一小段连 ...
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
随机推荐
- JNI_Z_03_类中的字段和方法的签名
1. Java类型 相应的签名 例子 boolean Z byte B char C short S int I long L float F double D void V Object L用&qu ...
- ES使用中遇到的多种坑,以及解决方案
1.查询不到导致404报错 在使用get或者search进行查询获取文档的时候,如果没有结果会抛出404的异常. 我们当然不希望抛出异常,这时候就要使用ignore这个参数来忽略报错,ignore可以 ...
- 用fail2ban阻止ssh暴力破解root密码
安装fail2ban工具来实现防暴力破解,防止恶意攻击,锁定恶意攻击IP. 1.如果是centos系统,先yum安装fail2ban [root@VM_152_184_centos /]# yum - ...
- react layout init
class Layout extends React.Component { constructor(props) { super(props); } render() { return ( < ...
- 移植 MIUI Framework
移植MIUI Framework 原文:http://www.miui.com/thread-409543-1-1.html 1. 为什么使用代码插桩 首先我们来回顾第一章中的Android软件架构图 ...
- 前端之HTML补充
一.列表 (1).无序列表<ul> <body> <ul type="disc"> <li>属性一</li> <l ...
- display:box属性
在移动端开发的时候,圣杯布局,弹性盒,是我们经常会用得到的,W3C很久以前就有一个display:box属性 flex是最新的,但是在实际的浏览器测试中,display: flex 不能完全替代dis ...
- 火狐下的GreaseMonkey和Chrome下的tampermonkey使用手记
说明:GreaseMonkey的作用是让我们浏览器运行我们自己写的脚本,而且是在后台一直不断的运行,听着就让人兴奋. [ps:他们当然可以创建名单对哪些网站作用或者排除哪些站点]: 开始了:Greas ...
- 【转载】 用 Windows API “GetAdaptersInfo” 获取 MAC 时遇到的问题
From:http://blog.csdn.net/weiyumingwww/article/details/17554461 前段时间有个项目需要获取客户端的 MAC 地址,用作统计去重的参考数据. ...
- HDU - 6041:I Curse Myself(Tarjan求环&K路归并)
There is a connected undirected graph with weights on its edges. It is guaranteed that each edge app ...