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 ...
随机推荐
- libnetwork 源码浅析
[编者的话]从docker 1.6开始关注docker网络这块,从原来的铁板一块,到后来的libnetwork拆分,到现在的remote driver,docker 一直在改进.功能缺失,实用性不足, ...
- C++(二十一) — 引用概念及本质
1.引用概念 引用是别名,必须在声明的时候初始化.即:是指一个已定义变量的别名.(一个内存空间,有两个名字都可以操作) 引用:在函数调用时,是变量的别名,不可以单独存在,使用时必须要初始化: 指针: ...
- java JVM 随笔
先说重点: 对象在堆区 方法在栈区 变量在方法区,常量池在方法区 为什么要了解Java 虚拟机 ? 这个问题一直困惑了我很长一段时间,其实在我们开发的过程中,即使我们不了解JVM也能正常的开发,但是当 ...
- go 编译
linux: set GOARCH=amd64 set GOOS=linux go build -o app_name main.go echo "编译完成,任意键退出" paus ...
- VMware虚拟机克隆Linux系统引起的网卡问题
1. 手动配置静态网卡地址不生效2. 网卡名变成了eth1[root@localhost network-scripts]# ls |grep ifcfg ifcfg-eth0 ifcfg-lo [r ...
- js & jquery数组介绍
(转自:http://www.jb51.net/article/30793.htm) 1.数组的创建 var arr=new Array(); 2.查找数组中的元素 for(var i=0;i< ...
- hibernate框架环境搭建与使用
搭建环境 一.新建一个项目 , 导包 一个是hibernate的jar包,一个是jdbc的jar包 hibernate的jar包 这些jar包全部导入 二.配置Hibernate. 1.建立hib ...
- 大马猴队-Alpha阶段项目复审
队名 优点 缺点 名次 菜鸡互坑队 经典游戏,情怀加分. 刷新的苹果会在蛇身上出现 14 菜鸡互啄 利用python语言实现git版本管理,典型用户清晰. 没有很好地分析用户痛点,没有测试计划 4 ...
- 浅析C#中抽象类和接口的区别
声明方法的存在而不去实现它的类被叫做抽象类(abstract class),它用于要创建一个体现某些基本行为的类,并为该类声明方法,但不能在该类中实现该类的情况.不能创建abstract 类的实例.然 ...
- WinForm与Javascript交互
在应用程序的集成过程中,有时候需要WinForm应用程序和Javascript程序进行交互.比如说:应用程序是一个综合调度系统,在整个综合调度系统中,要实现定位,显示地图.综合调度平台的大部分功能都是 ...