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 ...
随机推荐
- Python 数据分析练习1
环境 Anaconda3 Python 3.6, Window 64bit 目的 从MySQL数据库读取数据,进行数据清理,数据展示 代码 # -*- coding: utf-8 -*- import ...
- Shell 自定义函数
语法: function fname() { 程序段} 例子: #!/bin/bash ## 定义函数,分子除以分母,算利润.占有率等## 参数1:分子## 参数2:分母 function divfu ...
- SmsUtils 发送短信
import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import j ...
- 三十八 Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)介绍以及安装
elasticsearch(搜索引擎)介绍 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticse ...
- VMware虚拟机克隆Linux系统引起的网卡问题
1. 手动配置静态网卡地址不生效2. 网卡名变成了eth1[root@localhost network-scripts]# ls |grep ifcfg ifcfg-eth0 ifcfg-lo [r ...
- mysql-5.7.17的最新安装教程
mysql-5.7.17-winx64是现在最新版本的Mysql,这是免安装的,所以要进行些配置 下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mys ...
- LeetCode OJ:Best Time to Buy and Sell Stock(股票买卖的最佳时期)
Say you have an array for which the ith element is the price of a given stock on day i. If you were ...
- [转载]SVN trunk、branch、tag的用法
Subversion有一个很标准的目录结构,是这样的. 比如项目是proj,svn地址为svn://proj/,那么标准的svn布局是 svn://proj/|+-trunk+-branches+-t ...
- AS3中ASCII码和字符互转函数
AS3中ASCII码和字符互转函数 字符转成ASCII码: 格式:字符串变量.charCodeAt(字符位置); var str:String = “A”; trace(str.charCodeAt( ...
- 跟我学Delphi Xe4 开发 IOS 一 , 重读Delphi Xe4 自带文档.
安装了 Delphi Xe4 之后打开这个地址就是完整的官方的文档了. 虽然不是立刻能解决你的问题. 但也是必须要看一遍的. 最基础的都在这里了. ms-help://embarcadero.rs_x ...