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 ...
随机推荐
- Android并发编程之白话文详解Future,FutureTask和Callable
从最简单的说起Thread和Runnable 说到并发编程,就一定是多个线程并发执行任务.那么并发编程的基础是什么呢?没错那就是Thread了.一个Thread可以执行一个Runnable类型的对象. ...
- 【python教程】Python IDE
PyCharm PyCharm是由JetBrains打造的一款Python IDE. PyCharm具备一般 Python IDE 的功能,比如:调试.语法高亮.项目管理.代码跳转.智能提示.自动完成 ...
- Word批量设置表格宽度自动适应页面宽度
怎么批量修改Word表格的宽度呢.Word表格可根据窗口自动调整表格宽度,使得所有的表格宽度和页面宽度一样. 当页面设置了新的页边距后,所有的表格都需要调整新的宽度.或者文档中有许多大大小小的表格,希 ...
- .net操作Oracle数据库步骤及方法
1.首先安装PL/SQL Developer Oracle客户端软件 2.安装Oracle Instant Client(即时客户端) 安装与配置 配置环境变量ORAClE HOME 地址为insta ...
- Ubuntu 配置静态ip的方法
1. 配置静态ip地址 $sudo vi /etc/network/interfaces 原有内容只有如下两行: auto lo iface lo inet loopback 向末尾追加以下内容: a ...
- linux应用之wget命令详解
wget是linux最常用的下载命令, 一般的使用方法是: wget + 空格 + 要下载文件的url路径 例如: # wget linuxsense.org/xxxx/xxx.tar.gz" ...
- vue.js相关资料
1.https://cn.vuejs.org/v2/guide/ (中文文档)
- 数据挖掘算法Analysis Services-基于SQL Server的数据挖掘
数据挖掘算法(Analysis Services – 数据挖掘) data mining algorithm is a set of heuristics and calculations that ...
- 019对象——对象 method_exists property_exists instanceof
<?php /** * 19 对象 method_exists property_exists instanceof */ //method_exists() 判断方法是否存在,第一个参数对象或 ...
- Maven项目中java类报错-Cannot resolve symbol
电脑蓝屏了,强制重启之后再打开IDEA里面的项目,所有Java类文件都在报Cannot resolve symbo错误,可以确定所有依赖的包都有引用且jar包没有冲突. 经查询找到这个解决方法: 在I ...