1140 Look-and-say Sequence (20 point(s))

BCIC IV 2a数据集实战:从MATLAB导入到EEG信号分析全流程 本文提供了BCIC IV 2a数据集从MATLAB导入到EEG信号分析的完整实战流程。详细解析了数据集结构,区分了EEG与EOG信号,并演示了信号可视化、基础预处理(滤波、分段、基线校正)等关键步骤,帮助脑机接口研究者快速上手处理这一经典运动想象数据集。 阅读详情

1140 Look-and-say Sequence (20 point(s))

Look-and-say sequence is a sequence of integers as the following:

D, D1, D111, D113, D11231, D112213111, ...

where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number means that there is one D in the 1st number, and hence it is D1; the 2nd number consists of one D(corresponding to D1) and one 1 (corresponding to 11), therefore the 3rd number is D111; or since the 4th number is D113, it consists of one D, two 1's, and one 3, so the next number must be D11231. This definition works for D = 1 as well. Now you are supposed to calculate the Nth number in a look-and-say sequence of a given digit D.

Input Specification:

Each input file contains one test case, which gives D (in [0, 9]) and a positive integer N (≤ 40), separated by a space.

Output Specification:

Print in a line the Nth number in a look-and-say sequence of D.

Sample Input:

1 8

Sample Output:

1123123111

模拟题。思路比较简单。

注意点:

1. int2string()的实现;

2. 在nextString()遍历完成后,还需要针对字符串末尾的结果处理。

#include<iostream>
#include<cstring>
using namespace std;
string int2string(int n){
	string ans ="";
	do{
		ans = char(n%10+'0')+ans;
		n/=10;
	}while(n);
	return ans;
}
string nextString(string s){
	int cnt=0;string ans = "";
	for(int i=0;i<s.length();i++){
		if(i==0) cnt=1;
		else{
			if(s[i]==s[i-1]){
				cnt++;
			} 
			else{
				ans += s[i-1];
				ans += int2string(cnt);
				cnt=1;
			}
		}
	}
	ans+= s[s.length()-1];
	ans+= int2string(cnt);
	return ans;
}
int main(void){
	string s;int N;cin>>s>>N;
	if(N>=2){
		for(int i=0;i<N-1;i++){
			s = nextString(s);
		}
	} 
	cout<<s<<endl;
	return 0;
}

 

uniapp - 超详细的 H5 公众号网页微信登录示例代码,提供从 0-1 公众号配置及详细注释代码(站在新手小白的角度)第三方微信授权登录的实现!! uniapp微信浏览器H5授权微信登录,UniApp开发H5接入微信登录的全过程,uniapp的H5页面使用微信登录,uniapp H5微信授权登录,H5之微信授权登陆 (uniapp网页版微信授权登录),uni-app开发H5第三方微信授权登录的实现,uniapp如何实现微信授权登录,公众号H5页面接入微信登录流程,uni-app - 最详细 H5 网页接入微信登录功能,提供公众号配置与详细注释示例代码(移动端网页实现点击登录按钮后 调用微信公众号授权登录功能 详细讲解接入流程与详细示例代码)官方最新超级 阅读详情

相关推荐

告别虚拟机!用ZYNQ7000和PYNQ 2.6.0打造一个能实时识别人脸的“智能摄像头”

本文详细介绍了如何利用Xilinx ZYNQ7000开发板和PYNQ 2.6.0框架构建实时人脸识别系统。通过硬件加速和嵌入式开发技术,该系统实现了低延迟、低功耗的独立运行能力,适用于边缘计算和物联网应用。文章包含从环境搭建到核心功能实现的完整指南,并提供了性能优化和问题排查的实用技巧。

weixin_42543046的博客 393

PAT 1140 Look-and-say Sequence python解法

1140 Look-and-say Sequence (20 分) Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, … where D is in [0, 9] except 1. The (n+1)st number is a kind...

qq_36936510的博客 378

STM32实战:5分钟搞定CanFestival协议栈下的CANopen心跳报文配置(附避坑指南)

本文详细介绍了如何在STM32平台上使用CanFestival协议栈快速配置CANopen心跳报文,包括硬件准备、协议栈移植、心跳报文配置及常见问题解决方案。通过实战步骤和避坑指南,帮助开发者高效实现节点状态监控,提升工业控制系统的可靠性。

win55的博客 749

1140 Look-and-say Sequence(22行代码+详细注释)

分数 20全屏浏览题目切换布局作者 CHEN, Yue单位 浙江大学whereDDD1;DD1D111;

m0_66329385的博客 412

用Typora画流程图和序列图:Mermaid语法实战教程(含常见报错解决)

本文是一份详细的Typora与Mermaid语法实战教程,教你如何在Markdown文档中高效绘制流程图和序列图。文章涵盖从环境配置、核心语法到复杂图表构建的全过程,并重点解析了常见报错原因与解决方案,助你将可视化图表无缝融入文档工作流。

weixin_29279101的博客 301

Simulink Test Sequence自动化测试实战:从Excel到模型验证

本文详细介绍了如何利用Excel和MATLAB脚本实现Simulink Test Sequence的自动化测试。通过设计结构化Excel模板管理测试数据,并调用Simulink Test API批量创建与执行测试用例,该方法能显著提升复杂模型单元测试的效率,便于集成到CI/CD流程,实现从数据到验证的全自动化。

weixin_29261711的博客 144

PAT-python-1140 Look-and-say Sequence

Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, … where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number means that there is one D i

陆沙的博客 887

mongoDB 数据莫名其妙的没了

问题 之前没有接触过mongoDB,然后接手一个项目使用的是MongoDB,我就跟着网上的教程搭建一个MongoDB的服务,并运行起来。 一开始没有啥问题,成功的把服务与MongoDB都启动以来,运行也没有问题。但是过了几天,我再次打开时发现,以前的数据神奇的消失了。我还在想,是有什么定时清除的么,还是什么原因导致崩了然后数据就被清理了。 查找原因 第一次遇到我没有在意,重启了一下MongoDB,...

技术熊的博客小窝 1万+

PAT甲级 1140 Look-and-say Sequence (20分) 字符串处理/C++

1140 Look-and-say Sequence (20分) 字符串处理 题目大意:这题和LeetCode里面的38. Count and Say(可以看看LeetCode的各种题解)差不多。只不过say和count的位置相反。 #include<iostream> //输入输出流头文件 #include<stack> //栈 #include<string>

qq_43955154的博客 326

AI测试干货:Claude Code Skill 从入门到精通

本文介绍了Claude Code Skill功能如何解决AI重复工作问题。传统提示词方式需要人工复制粘贴,而Skill功能通过建立AI工作记忆库实现智能触发和分层加载。Skill包含工作指令、文档和资源,能自动执行任务。文章以API测试用例生成为例,展示了Skill的创建流程和结构化设计,包括测试框架、覆盖场景和输出格式,显著提升测试工程师的工作效率。

blues_C的博客 2445

工业仪表读数识别:YOLO目标检测 + OCR混合方案实战

仪表整体(meter):粗定位整只仪表,用于快速裁剪、排除背景干扰表盘区域(dial):精确的圆形/方形表盘区域,用于后续矫正和读数数字区域(display)/指针(pointer):数显表定位数码管区域,指针表可辅助定位指针为什么要分三级?因为现场仪表安装角度、距离、光照差异极大。先粗检再精检,比一步到位的准确率高很多,也方便后续做透视变换。工业仪表读数识别,技术路线的选择比算法精度更重要。选对了路线,事半功倍;选错了,怎么调都达不到验收标准。几条落地建议:指针表优先传统算法。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 97

【PAT】A1140 Look-and-say Sequence【字符串处理】

Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, … where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number....

elegant coder 1045

OpenHarmony WiFi子系统全解析:从架构到代码实现(大合集)

头文件路径[相对路径][相对路径][相对路径][相对路径]// 网络配置结构 (wifi_device_config.h)// SSID字符串// 预共享密钥// 安全类型// 网络ID// 优先级// 是否隐藏网络// 扫描信息结构 (wifi_scan_info.h)// SSID// BSSID (MAC地址)// 安全类型int rssi;// 信号强度// 频率// 信道宽度// 时间戳// 连接信息结构 (wifi_linked_info.h)

m0_67505153的博客 1061

【PAT】A1140 Look-and-say Sequence (20point(s))

文章目录A1140 Look-and-say Sequence (20point(s))Input Specification:Output Specification:Sample Input:Sample Output:CodeAnalysis Author: CHEN, Yue Organization: 浙江大学 Time Limit: 400 ms Memory Limit: 64 MB...

Duke 247

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

1140 Look-and-say Sequence (20 point(s))

思路: 字符串处理,识别连续的digit个数。 1140 Look-and-say Sequence (20 point(s)) Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, ... whereDis in [0, 9] except 1. The (n+1)st number is a kind of description o..

专栏 224

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

1140 Look-and-say Sequence (20 point(s))

#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;string&gt; using namespace std; string res; int n; int main() { cin &gt;&gt; res &gt;&gt; n; for(int i = 0; i &lt; n - 1; ++i) { char...

徐伯莱 273

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

1140 Look-and-say Sequence (20point(s)) - C语言 PAT 甲级

* 每次利用前一个字符串生成下一个字符串,难点似乎在于如何确定字符数组的大小(实际上,数组大小多提交几次就能知道了(╥﹏╥))?或者是我未体会到此题的精髓? * 求大佬解答_(┐「ε:)_

有三只土豆 217

PAT_甲级_1140 Look-and-say Sequence (20point(s)) (C++)【字符串处理】

目录 1,题目描述 题目大意 2,思路 3,AC代码 4,解题过程 1,题目描述 Sample Input: 1 8 Sample Output: 1123123111 题目大意 ( 看了N遍,终于。。。)直接介绍例子吧 D D1(对1的描述:只有一个D) D111(对2的描述:一个D,一个1) D113(对3的描述:一个D,三个1) D11231...

&再见萤火虫&的博客 275

PAT(A) 1140 Look-and-say Sequence (20 point(s))

#include<bits/stdc++.h> using namespace std; int main(void){ int D, N; scanf("%d %d", &D, &N); vector<int> va, vb; va.push_back(D); for(int i = 0; i < N-1; i++){ int p1 = 0, p2 = 0; while(p1

Anpotan的博客 555

PAT 1140 Look-and-say Sequence (20point(s))(解题记录)

Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, … This problem asks to find the Nth Look-and-say sequence of a given digit. My Idea The main data structure I used is a queue Q that stores every temp.

momoomoo的博客 213

1140 Look-and-say Sequence (20 分)

Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, ... where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth n...

x_zjudream的博客 179

1140. Look-and-say Sequence (20)

#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;algorithm&gt; using namespace std; string get_num(string &amp;s){ string sa = ""; for(int i = 0; i &lt; s.length(); i++){ ...

pacmo 461

PAT 甲级 1140 Look-and-say Sequence (20 分) 模拟

题意: 先给一个数D(看作字符串)然后每次变化时把这个字符串中 字符相同的连续一段映射成两个信息加入新的串 这两个信息为: 相同的这个字符,这个字符的数目 D -> D1 D1 -> D1 11 D111 -> D1 13 D113 -> D1 12 31 D11231-> D1...

床前明月光 257

【PAT】1140 Look-and-say Sequence 最后一个测试点超时问题

1140 Look-and-say Sequence Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, … where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number

目标:NLP算法工程师 367

Look and say 源码分析

Look and say 源码分析:Code: #include     #include     #include     // each subsequent element is defined from the    //previous one by "verbally"    //For exam the 

jxusthusiwen的专栏 535

1140 Look-and-say Sequence (20分) 解决测试点4超时 详解

Input Specification: Each input file contains one test case, which gives D (in [0, 9]) and a positive integer N (≤ 40), separated by a space. Output Specification: Print in a line the Nth number in a look-and-say sequence of D. Sample Input: 1 8 Sample Out

weixin_43957537的博客 324
上一篇: 1114 Family Property (25 point(s))
下一篇: 1141 PAT Ranking of Institutions (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值