PAT甲级1050,1051解题报告

RK806S PMIC电源管理芯片调试 当点按PWRON按键时,rk806上电开始启动bootloader和uboot,在执行到此处时检测到是由于按键启动的,所以0x5d的值是0x80,0x74的值是0x80,在一般情况下,mode都默认是none的,所以mode值为11,因此就进入了我们的if判断,若是由于按键启动的,则直接调用rk8xx_shutdown函数关掉,进入这个函数会看到实际是通过i2c给0x72寄存器的BIT(0)写1,使其关机。当SoC在12V电源已经接入,且处于关机状态时,使用PWRON按键开机,0x74的值则为0x80。 阅读详情

 

1050 String Subtraction (20 point(s))

Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ for any given strings. However, it might not be that simple to do it fast.

Input Specification:

Each input file contains one test case. Each case consists of two lines which gives S​1​​ and S​2​​, respectively. The string lengths of both strings are no more than 10​4​​. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.

Output Specification:

For each test case, print S​1​​−S​2​​ in one line.

Sample Input:

They are students.
aeiou

Sample Output:

Thy r stdnts.

题目大意:给两个字符串,给出S1-S2,其中减法规则是把前者里面在后者字符串中存在的字符全部删去。

解题思路:However, it might not be that simple to do it fast.别被这句话吓到。。其实很水。

用set存一下第二个字符串,然后对第一个字符串进行遍历,直接用STL的find函数就行了,如果在集合里找得到,就不输出,找不到就输出。

代码如下:

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<list>
#include<climits>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
set<char> m;
int main()
{
	string a, b;
	getline(cin, a);
	getline(cin, b);
	for (int i = 0; i < b.size(); i++)m.insert(b[i]);
	for (int i = 0; i < a.size(); i++) {
		if (find(m.begin(), m.end(), a[i])==m.end()) {
			cout << a[i];
		}
	}
	cout << endl;
	return 0;
}

1051 Pop Sequence (25 point(s))

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain 1, 2, 3, 4, 5, 6, 7 from the stack, but not 3, 2, 1, 7, 5, 6, 4.

Input Specification:

Each input file contains one test case. For each case, the first line contains 3 numbers (all no more than 1000): M (the maximum capacity of the stack), N (the length of push sequence), and K(the number of pop sequences to be checked). Then K lines follow, each contains a pop sequence of N numbers. All the numbers in a line are separated by a space.

Output Specification:

For each pop sequence, print in one line "YES" if it is indeed a possible pop sequence of the stack, or "NO" if not.

Sample Input:

5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6 4 3 7 2 1
1 7 6 5 4 3 2

Sample Output:

YES
NO
NO
YES
NO

题目大意:就是数据结构笔试经常做到的。。告诉你一个进堆栈的序列,然后给你一些出栈的序列,判断这种是否合法,注意一下这里的堆栈有大小限制,也就是堆栈满了就必须pop

解题思路:新建一个堆栈模拟一下,每次从1开始读,进栈之后判断,是不是超出限制了,如果超出了,不用继续,直接就是不合法的。如果没超出,那继续判断是不是和当前数组指针指向的数一致,如果一致,就pop,如此一直继续到不相等或者栈空即可。

代码如下:

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<list>
#include<climits>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
using namespace std;

int main()
{
	int M, N, K;
	cin >> M >> N >> K;
	while (K--) {
		stack<int> tmp;
		vector<int> a;
		for (int i = 0; i < N; i++) {
			int c;
			cin >> c;
			a.push_back(c);
		}
		bool flag=true;
		int index = 0;
		for (int i = 1; i <= N; i++) {
			tmp.push(i);
			if (tmp.size() > M) {
				flag = false;
				break;
			}
		     while(!tmp.empty() && tmp.top() == a[index]) {
				
					tmp.pop();
					index++;
				}
			
		}
		if (tmp.empty()&& flag == true) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

 

【机器视觉】基于深度学习的托盘PCB识别与计数(有无、正反) 工业机器视觉是指在制造业和工业环境中使用计算机视觉技术来执行检测、测量、识别和控制任务。它结合了硬件(如相机、镜头、光源)与软件(图像处理算法)来自动完成传统上需要人工视觉的任务,从而提高生产效率、产品质量以及工作安全性。工业机器视觉系统通常具有高精度、高速度和高可靠性,能够适应恶劣的工作环境。 阅读详情

相关推荐

【cocos2dx面试题干货】--2021年最新cocos2dx面试干货(引擎篇)

【cocos2dx面试题干货】--2020年度最新cocos2dx面试干货(引擎篇 ) 大家好,我是Lampard~~ 经过春招一番艰苦奋战之后,我终于是进入了心仪的公司。 今天给大家分享一下我在之前精心准备的一套面试知识。 由于我面试的岗位是cocos2dx的开发岗,今天就先给大家分享一下引擎方面的知识。 本人亲测80%的引擎相关题目都...

Lampard的博客 1万+

PAT basic 1051 复数乘法 (15分) C++ 测试点3 错误点详解

一、题目描述 复数可以写成 (A+Bi) 的常规形式,其中 A 是实部,B 是虚部,i 是虚数单位,满足 i​2=−1;也可以写成极坐标下的指数形式 (R×e​(Pi)),其中 R 是复数模,P 是辐角,i 是虚数单位,其等价于三角形式 R(cos§+isin§)。 现给定两个复数的 R 和 P,要求输出两数乘积的常规形式。 输入格式: 输入在一行中依次给出两个复数的 R1​​ , P​1​​ ,...

雨渊的博客 730

2026年电子学会青少年C++四级考纲解析与备考指南

C++作为面向对象编程的核心语言,其语法结构与算法设计是计算机科学的基础。理解循环嵌套、多分支判断等控制结构,掌握排序查找等基础算法,能够有效提升代码执行效率。在工程实践中,文件读写操作和异常处理是保证程序健壮性的关键技术。2026年电子学会青少年等级考试新版大纲特别强调算法效率分析和调试能力,反映了行业对代码质量与工程实践能力的重视。针对四级考试,考生需要重点掌握VS Code开发环境配置、时间复杂度计算等新增要求,这些技能在软件开发、数据分析等应用场景中具有广泛价值。

weixin_30086969的博客 114

1051 复数乘法 (15 分)——测试点2,3分析

今天去pta练手,卡在了一道15的题目上,话不多说先看一下题目 复数可以写成(A+Bi)的常规形式,其中A是实部,B是虚部,i是虚数单位,满足i​2​​=−1;也可以写成极坐标下的指数形式(R×e​(Pi)​​),其中R是复数模,P是辐角,i是虚数单位,其等价于三角形式R(cos(P)+isin(P))。 现给定两个复数的R和P,要求输出两数乘积的常规形式。 输入格式: 输入在一行中依次给出两个复数的R​1​​,P​1​​,R​2​​,P​2​​,数字间以空格...

小开心的博客 449

基于 Go 的微信滑块验证码自动化:协议还原与图像算法深度解析

本文从协议层、算法层和工程优化三个维度,系统拆解了基于Go的微信滑块验证码自动化方案。在协议层,通过手写protobuf编码器和RSA加密复现了微信UUID生成机制;在算法层,采用图像匹配技术实现滑块缺口定位;在工程层面,构建了包含HTTP状态机和随机化设备指纹的完整验证流程。文章重点阐述了技术实现的形式化建模、算法选择依据和复杂度分析,为工程师和算法研究者提供了可验证的技术方案。核心代码结构包括UUID生成、滑块状态机和图像匹配算法等模块,通过分层设计实现了高效可靠的验证码自动化破解。

weixin_65409651的博客 1319

终端效率神器:Tmux 安装与使用全指南

终端效率神器:Tmux 安装与使用全指南

身在被窝_心在编程 1403

1051 复数乘法 (15分)及测试点2、3错误分析

1051 复数乘法 (15分)及测试点2、3错误分析 复数可以写成 (A+Bi) 的常规形式,其中 A 是实部,B 是虚部,i 是虚数单位,满足 i​2=−1;也可以写成极坐标下的指数形式 (R×e​(Pi)),其中 R 是复数模,P 是辐角,i 是虚数单位,其等价于三角形式 R(cos(P)+isin(P))。 现给定两个复数的 R 和 P,要求输出两数乘积的常规形式。 输入格式: 输入在一行中...

唯爱你不弃∞ 686

Cadence OrCAD Capture 原理图中创建差分对约束的两种常用方法

本文介绍在原理图设计阶段,添加差分对的方法。

fydar的博客 3948

PAT甲级1050 String Subtraction

题目 1050 String Subtraction (20 分) Given two strings S​1 and S​2 , S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S​1. Your task is simply to calculate S​1−S​2...

领导的博客 294

从零开始跑通3DGS教程:(四)修改(缩放、空间变换)colmap生成的sfm结果

通过colmap进行的sfm的普通方式会丢失场景的物理尺度信息,并且并不在符合一般认知的坐标系下,本文将读取colmap生成的点云和相机pose,将其进行空间变换和缩放之后,重新保存,新保存的结果仍然可以被colmap读取以及进行后续的稠密重建以及3dgs等工作

诺有缸的高飞鸟的博客 1434

YOLOv8改进 | 注意力篇 | 一文带你改进GAM、CBAM、CA、ECA等通道注意力机制和多头注意力机制

官方论文地址:官方论文地址点击此处即可跳转官方代码地址:官方代码地址点击此处即可跳转GAM旨在通过设计一种机制,减少信息损失并放大全局维度互动特征,从而解决传统注意力机制在通道和空间两个维度上保留信息不足的问题。GAM采用了顺序的通道-空间注意力机制,并对子模块进行了重新设计。具体来说,通道注意力子模块使用3D排列来跨三个维度保留信息,并通过一个两层的MLP增强跨维度的通道-空间依赖性。

Snu77的博客 4万+

PAT甲级 1050 String Subtraction (20分)

1050 String Subtraction (20分) 题目链接:PAT A 1050 题目大意:给出两个字符串s1和s2,要求在s1字符串中去掉s2字符串中出现过的所有字符并输出。 思路分析:这道题很基础,直接用string结合map解决就可以。遍历一遍s2字符串,用map记录其中出现过的字符,然后遍历s1字符串,如果某个字符map值为0,说明没有在s2中出现过,直接输出,否则不输出。 注...

weixin_43684054的博客 218

Android Audio录音——AudioRecord回声消除(九)

在语音通话或录音场景中,回声(Acoustic Echo)通常是指说话的声音从对方的扬声器播放出来,又被对方的麦克风拾取,然后有被传回来,导致我们听到了自己延迟了一段时间的重复声音。

小旭的专栏 1419

C++版浙大PAT乙级1051(15分)测试点3答案错误解决办法

https://pintia.cn/problem-sets/994805260223102976/problems/994805274496319488 这15分不容易啊,有许多细节。测试点3的错误在于,计算出实部和虚部的时候,因为它们都要保留两位小数,会出现 -0.00 的情况,这个时候就不能带负号。 也就是说,如果实部或虚部是 -0.001、-0.002、...、-0.004、-0.004999,即小于0、大于0.005的时候,它们是不要带负号的。 #include<iostream.

Hillbox 281

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

hash学习patA1050 String Subtraction

hash类型的基本做法: 1.录入hash数据,并且保存原始数据 2.根据hash数据进行处理 字符串常见的边界情况: 1.一个是空字符串 2.字符串s1的长度和s2的长度不一定,需要注意处理情况 #include <iostream> #include<string> #include<stdlib.h> #include<stdio.h> #include<string.h> #include<algorithm> //1050 S

qq_43702629的博客 213

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

pat甲级1051

#include &lt;iostream&gt; #include&lt;stdlib.h&gt; #include&lt;vector&gt; using namespace std; vector&lt;int&gt;v; int m, n, k; bool isok() { vector&lt;int&gt;test; int maxnum = 0;//入过栈的最大值 for (i...

csdnnmbdybb的博客 242

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

【PAT甲级 - C++题解】1050 String Subtraction

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 410

PAT甲级1050:String Subtraction (20)

题目 Given two strings S1 and S2, S = S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1−S2 for any given strings. However, it might not be that simple to do it fast. Input Specifica

博客简介 352

PAT-1050 String Subtraction

1050 String Subtraction(20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calcul...

Eric的博客 311

PAT甲级 A1050

PAT甲级 A1050 题目详情 1050 String Subtraction (20分) Given two strings S1 and S​2, S=S​1−S2is defined to be the remaining string after taking all the characters in S2 from S1 . Your task is simply to calculate S1−S​2 for any given strings. However, it might not

weixin_44065549的博客 242

PAT A 1051(甲级)

1051 Pop Sequence(25 分) 作者: CHEN, Yue 单位: 浙江大学 时间限制: 400 ms 内存限制: 64 MB 代码长度限制: 16 KB Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop rando...

CrazyOnes的博客 742

PAT甲级1051 栈的模拟

题目 1051 Pop Sequence (25)(25 分) Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers...

小夏要科学进步 502

PAT甲级1050(字符串减法)

1050 String Subtraction (20 point(s))   Given two strings S​1 and S​2, S=S​1−S​2 is defined to be the remaining string after taking all the characters in S​2 from S​1. Your task is simply to calculate...

云胡的博客 273

PAT - 甲级 - 1050. String Subtraction (20)(Hash映射)

Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However,

i逆天耗子 526

1050 String Subtraction(20 分)

1050 String Subtraction(20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calcul...

galesaur_wcy 405

PAT 1051. Pop Sequence (25)

1051. Pop Sequence (25) 时间限制 10 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Given a stack which can keep M numbers at most. Push N numbers in t

神州之光的专栏 748
上一篇: PAT甲级1048,1049解题报告
下一篇: PAT甲级1052,1054解题报告
Tate_Brown
博客等级 码龄9年 39粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址