用python来解 PAT乙级1072开学寄语-20-满分

浙大PAT advanced level 1001--1091答案代码 浙大pat甲级1001到1091题目答案,供参考。 立即下载

题意大概:给出违禁品编号和每个学生带的物品编号,输出学生所带的违禁品,带违禁品的学生数量以及违禁品总数

格式的学生姓名加冒号(:)可以直接自己定下之后再进行判断 直接将违禁物品编号加在后面进行输出

然后我是设置变量来统计查缴物品总数,直接将带了违禁品的学生姓名加入列表,输出列表长度

n , m = map(int,input().split())#学生数 违禁物品数
wu = [i for i in input().split()]#需要被查缴的物品编号
res = []
x = 0#设置变量来统计查缴总数
for j in range(n):
    stu = [i for i in input().split()]
    shuchu = stu[0] + ':' #直接设置输出格式
    for k in stu[2:]:#遍历学生带的物品
        if k in wu:
            shuchu = shuchu +' ' +k#查缴物品直接加在输出字符后面
            x +=1#统计总数
    if shuchu != stu[0] + ':':#有问题的学生  输出加入列表
        res.append(shuchu)
for h in res:#统一输出
    print(h)
print(len(res) , x)#有问题的学生数,查缴的物品数

提交结果:

浙江大学pat题目集合(1001-1072) 浙江大学的程序能力测试(pat)上所有advanced级别的题目集合,从1001到最新的1072全部都有 立即下载

相关推荐

SPD5 集线器协议内容解析

​ 若不同SPD5 Hub后面的本地侧设备同时发送请求,则是22和23、24的混合过程,先通过LID裁决,再通过HID裁决,这里的LID是本地设备的,若LID一致,则看HID,由于SPD5 Hub的本地侧设备HID均为111,因此实际上是比较SPD5 Hub的HID,这个过程在前文提到,SPD5 Hub会转换HID。​ 若MR27[4]=1且MR27[3:0]=1,如果MR51[3:0]=1时,发送IBI,并且MR48[7]置1,将GETSTATUS CCC的待处理中断位[3:0]更新为0001。

weixin_50591344的博客 3874

每日一题——Python实现PAT乙级1072 开学寄语(举一反三+思想解读+逐步优化)五千字好文

优点:代码结构清晰,逻辑处理合理,能够正确处理输入并输出结果。缺点:在移除物品时,使用 person_items.remove(i) 可能会导致线性时间复杂度,因为列表的 remove 操作是 O(k) 的。可以考虑使用集合(set)来优化这一部分。改进建议:可以使用集合(set)来存储禁止携带的物品列表,这样可以优化检查物品是否在禁止携带列表中的时间复杂度。同时,可以使用集合来存储每个学生携带的物品,以优化移除物品的操作。

weixin_44915521的博客 1008

深入解析JESD204B Periodic SYSREF在多ADC/DAC系统中的同步优化策略

本文深入探讨了JESD204B Periodic SYSREF在多ADC/DAC系统中的同步优化策略,针对雷达阵列和宽带通信系统中的同步精度问题,详细解析了硬件实现细节、参数配置实战经验及系统级优化方法。通过案例分析和技术要点,帮助工程师解决由温度漂移和时钟抖动引起的同步挑战,提升系统性能。

weixin_29267307的博客 143

1072 开学寄语(20 分)

1072 开学寄语(20 分) 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也! 本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。 输入格式: 输入第一行给出两个正整数 N(≤ 1000)和...

码奴生来就只知道前进 851

新手避坑指南:用SARScape 5.6.2处理Sentinel-1数据做SBAS-InSAR,这些参数设置错了白忙活

本文详细介绍了使用SARScape 5.6.2处理Sentinel-1数据做SBAS-InSAR时的关键参数设置技巧,帮助新手避免常见错误。重点解析了连接图生成、干涉工作流、DEM处理等环节的12个关键参数,包括Max Normal Baseline、Unwrapping Coherence Threshold等,提供实测安全值范围和优化建议,确保处理效率和结果准确性。

weixin_30694389的博客 574

Dify如何实现自主学习

摘要:Dify通过构建感知-决策-执行-反馈的闭环实现"自主学习",本质是打造能自动获取信息、更新知识库并调整策略的Agent工作流。核心包括:1)建立知识库作为记忆体;2)搭建感知与执行工具获取实时信息;3)通过工作流编排决策"大脑",包含LLM决策节点、行动执行节点和反馈反思节点。典型应用如根据用户反馈优化回答风格,通过存储反思日志到知识库实现持续优化。这种机制使智能体能基于新数据和经验不断自我改进。

专注于技术研发行业技术主要有AI人工智能视觉识别、物联网技术、电商平台、app原生技术、微信小程序、鸿蒙语言开发、办公企业oa、ERP等,致力于做东半球最优秀的程序员 732

PAT 乙级 1072 开学寄语 python

PAT 乙级 1072 开学寄语 python ac

m0_43424109的博客 367

ESXI 8.0.3 ubuntu 24.04 直通显卡P40

手把手,一步步教你直通GPU,ESXI 8.0.3 ubuntu 24.04 直通显卡P40

qq_36433118的博客 4695

全部博文链接汇总(不断更新)

用python来解 PAT 1001 害死人不偿命的(3n+1)猜想-15-满分 用python来解 PAT 1002 写出这个数 -20-满分 用python来解PAT乙级1042 字符统计-20-满分 用python来解 PAT乙级 1022D进制的A+B -20-满分 用python来解 PAT 1048数字加密-20-满分无超时 用python来解 PAT 1050螺旋矩阵-25-满分无超时 用python来解 PAT 1060爱丁顿数-25-满分无超时 用python来解 PAT 1061判断题-

pythonuser1的博客 361

标准恢复二极管整流器的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告

报告页数: 150 图表数: 100 报告价格:¥16800 本文研究全球与中国市场标准恢复二极管整流器的发展现状及未来发展趋势,分别从生产和消费的角度分析标准恢复二极管整流器的主要生产地区、主要消费地区以及主要的生产商。重点分析全球与中国市场的主要厂商产品特点、产品规格、不同规格产品的价格、产量、产值及全球和中国市场主要生产商的市场份额。 主要生产商包括: Yangzhou Yangjie Vishay Intertechnology Power Semiconductors Inc Nexperia B

Fj69258的博客 5863

在ubuntu20.04中安装MATLAB时常见问题及解决方法

   如果你刚装完ubuntu20.04,这时你想要安装MATLAB2021A,在输入命令./install进行安装时,可能会报以下错误:    terminate called after throwing an instance of ‘JailContainerException’ what(): Error: 88: No JRE version parsed from/media/jzx/MATHWORKS_R2021A/sys /java/jre/glnxa64/jre/release   

慕羽★的博客 1万+

pat 乙级 1072. 开学寄语(20)

1072. 开学寄语(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其QQ,封其电脑,夺其手机,收其ipad,

PasserbyQk 齐凯 2401

24年电赛H题 | 想要小车走直线,正在调角度环,但不知道怎么把角度偏航角偏差转化成电机速度输出?

🏆本文收录于 《全栈 Bug 调优(实战版)》 专栏。专栏聚焦真实项目中的各类疑难 Bug,从成因剖析 → 排查路径 → 解决方案 → 预防优化全链路拆解,形成一套可复用、可沉淀的实战知识体系。无论你是初入职场的开发者,还是负责复杂项目的资深工程师,都可以在这里构建一套属于自己的「问题诊断与性能调优」方法论,助你稳步进阶、放大技术价值 。

**My Coding Family** 1349

3.21 PAT1072 乙级 python

开学寄语 sn,tn = map(int,input().split()) t = [i for i in input().split()] q = 0 s = 0 lf = [] for i in range(sn): info = input().split() flag = 0 for j in info[2:]: for k in t: if j==k and flag...

棉毛裤穿吗 210

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

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

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

1072. 开学寄语(20)——Python

def judge(string_2, list_things, count_things): #判断是否有违禁物品 my_list = [] for thing in list_things: if thing in string_2: count_things += 1 my_list.append(thing) #print(thing) return my_l

baidu_38271024的博客 749

怀旧版电脑GBC模拟器

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

PAT 乙级(Python) #1072 开学寄语 (20 分)

#1072 开学寄语 (20 分) 代码展示: N, M = list(map(eval,input().split())) forfeit = input().split() count_stu, count_for = 0, 0 def check(info): global count_stu, count_for name = info[0] temp = [name+':'] for item in info[2:]: if item in fo

敲代码的小风 347

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

1072 开学寄语()

1072 开学寄语(20 分) 输入格式: 输入第一行给出两个正整数 N(≤ 1000)和 M(≤ 6),分别是学生人数和需要被查缴的物品种类数。第二行给出 M 个需要被查缴的物品编号,其中编号为 4 位数字。随后 N 行,每行给出一位学生的姓名缩写(由 1-4 个大写英文字母组成)、个人物品数量 K(0 ≤ K ≤ 10)、以及 K 个物品的编号。 输出格式: 顺次检查每个学生携带的物品...

qiulianshaonv_wjm的博客 325

PTA乙级1072,开学寄语

#include<bits/stdc++.h> using namespace std; int a[9999]={0};//先创建一个用于判断是否是违禁物品的数组 int main(){ int n,m,temp,k,snum=0,fnum=0,x; scanf("%d %d",&n,&m);//输入学生总人数和违禁物品数 for(int i...

天上的人我是谁的博客 272

PTA乙级1072

1072 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也! 本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。 输入格式: 输入第一行给出两个正整数 N(≤ 1000)和 M(≤ 6),分别是学生人数和...

贝爷的奇遇冒险 233

Python 水仙花数

水仙花数 while True: num = input('请输入一个3位数') num = int(num) if not (100 <= num <= 999): print('你输入的数据无效,直接退出程序') exit() baiwei = num // 100 shiwei = num % 100 //...

core571的博客 504

C++/Python PAT乙级1072 开学寄语 (20分)

下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad, 断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也! 本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。 输入格式: 输入第一行给出两个正整数 N(≤ 1000)和 M(≤ 6),分别是学生人数和需要被...

qq_42344132的博客 324

PTA 乙级 1072 开学寄语

代码实现: #include&amp;lt;stdio.h&amp;gt; int main() { int N, M, *want[10000], cnt_stu = 0, cnt_tool = 0; scanf(&quot;%d %d&quot;, &amp;amp;N, &amp;amp;M); for (int i = 0; i &amp;lt; 10000; i++) want[i] = 0; for (int i = 0;

Gaibb123的博客 266

PTA 1072 开学寄语 (c++ map+思路+测试点2)

思路:首先我用map将违规的编号对应的键值变为1;然后在每次输入学生的用品编号的时候用map判断,如果为1则存入一个新的数组中,并统计每个学生的违规数量和违规学生的数量。最后输出。 测试点2:最开始我都是用int接收值的,包括map也是int对int的映射。但是编号可能就是0123这种的,接收之后前导0就会不存在。所以我改用string来接收,map改为string对int的映射。当然,你可以...

qq_44622401的博客 453

1072 开学寄语 (20 分) python

N,M = map(int, input().split(" ")) list1 = input().split(" ") dict1 = {} people = 0 things = 0 for i in range(N): ipt_list = input().split(" ") for j in ipt_list[2:] : if j in list1 a...

weixin_41775301的博客 699

PAT 乙级 1072 开学寄语(20 分)

下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面、理发、整衣,然后思过、读书、锻炼、明智、开悟、精进。而后必成大器也!本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器。输入格式:输入第一行给出两个正整数 N(≤ 1000)和 M(≤ 6),分别是学生人数和需要被查缴的物品种...

Hickey_Chen的博客 837

PTA 1072 开学寄语(Python3)

PAT (Basic Level) Practice (中文)

weixin_55730361的博客 237
上一篇: 用python来解 PAT乙级 1071小赌怡情 -15-满分
下一篇: 用python来解 PAT乙级1081检查密码-15-满分
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址