用python来解 PAT 1060爱丁顿数-25-满分无超时

PTA部分习题解答 一、编程题 1、 求N分之一序列前N项和 :计算序列 1 + 1/2 + 1/3 + … 的前N项之和。 #include<stdio.h> int main() { int m,i,n; double item,sum; scanf("%d",&n); m=1; sum=0; for(i=1;i<=n;i++) { it... 阅读详情

根据题意,一组数据里面,有N个大于N的数据,求对于一组数据的最大N值

题目给出天数和每天的运动里程,第一步应该就是将数据排序,然后直接遍历加切片判断,至于递增还是递减可以思考看看,如果是递增数列,对于其后的数,只能保证是大于等于它的关系,如果同个数值有多个就显得麻烦了,所以我这里用的是递减,然后直接判断前面的数的个数就ok,代码如下:

n = int(input())#连续骑车的天数
l = [x for x in map(int,input().split())]
l.sort()
l.reverse()
sum = 0
for i in range(n):
    if l[i] > sum + 1:
        sum +=1
print(sum)

提交结果:

「PAT乙级真题解析」Basic Level 1060 爱丁顿数 (问题分析+完整步骤+伪代码描述+提交通过代码) 题设要求统计所有满足E天超过E英里的整数E, 然后给出E的最大值. 求一组数中的最大值是一个常规的过程, 所以本题的核心是如果统计所有E天超过E英里的E. 题设给出的数据形式是第i天跑了j英里, 我们需要统计的是跑超过j英里的天数. 所以我们需要先统计跑了j英里的天数, 然后从最大的距离开始, 将该距离加到小于这个距离的所有距离的天数统计中. 阅读详情

相关推荐

普通人如何上岸华为OD-面试总结

总共有3道算法题,100分值的两道,200分值的一道,不同的毕业院校和专业,通过机试的分值不一样,最少需要150分通过,提前和hr联系,了解自己需要多少分通过。重中之重:哪怕你是背的题库,也请你一定不要直接抄原来的,最好是变更下方法名,否则会判定你重复率过高,从而失去后面的面试机会(实在是不会做再用此方法,凑分数所用,面试官能看到你的代码,会影响你的面试评价)本人女,所以还问道了婚育计划,有对象这点可以说,没有问题,但是如果可以的话,生孩子的时间,可以给hr说这几年不考虑。如果说没有难题,直接就挂了。

weixin_47767264的博客 5496

PAT 乙级(Python) #1060 爱丁顿数 (25 分)

#1060 爱丁顿数 (25 分) 代码展示: N = eval(input()) miles = list(map(eval,(input().split()))) E = int(min(N,max(miles))) while True: temp = [item for item in miles if item>=E] if len(temp) >= E: break else: E -= 1 print(E) 测评结果:

敲代码的小风 275

告别配置迷茫:手把手教你用Vivado 2023.1配置Xilinx FPGA的DDR4 MIG IP核(含AXI接口详解)

本文详细介绍了如何在Vivado 2023.1中配置Xilinx FPGA的DDR4 MIG IP核,包括AXI接口的深度解析与优化。通过实战案例和调试技巧,帮助工程师快速掌握DDR4内存与FPGA的协同工作,提升系统性能。特别适合需要高性能计算和实时信号处理的开发者。

weixin_29231725的博客 457

【PAT_Python解】1060 爱丁顿数

多学习其他大佬的AC代码!

新时代先锋的博客 713

用PLECS搞定三相逆变器电流环:从传递函数推导到PI参数整定的保姆级教程

本文提供了一份详细的PLECS教程,指导如何从传递函数推导到PI参数整定,实现三相逆变器电流环的闭环控制。通过坐标变换、控制器设计和仿真验证等步骤,帮助工程师快速掌握电流环控制技术,提升电力电子系统的稳定性和可靠性。

weixin_27102543的博客 406

MDPI期刊投稿全流程解析:从注册到提交的实用指南

本文详细解析了向MDPI期刊投稿的全过程,从注册账号、完善个人资料、上传稿件,到填写作者信息、推荐审稿人及提交附信等关键步骤。指南强调了使用机构邮箱、遵循期刊模板、认真准备Cover Letter等实用技巧,旨在帮助作者高效、规范地完成投稿,避免常见错误,提升稿件处理效率。

weixin_29250403的博客 947

pat 乙类 1060 python

一、先降序排列,再查找E的值。序列号加1即为天数 二、将天数与骑车距离相比较即可 三、需考虑两种特殊情况,1、全部满足,2、全部不满足 n = int(input()) num = list(map(int,input().split())) num.sort(reverse=True) for i in range(n): if num[0] > i+1: if num[i] > i+1: if i == n-1:

qq_20662425的博客 164

利用大模型和聚类算法找出 Excel 文件中重复或相似度高的数据,并使用 FastAPI 进行封装的详细方案

tokenizer将输入的文本列表texts转换为 PyTorch 张量,同时进行填充和截断操作,以确保所有输入具有相同的长度。对输入进行推理,得到模型的输出。对模型的最后一层隐藏状态求平均,得到每个文本的向量表示。.numpy()将 PyTorch 张量转换为 NumPy 数组。使用DBSCAN算法对文本向量进行聚类。eps是邻域半径,是形成核心点所需的最小样本数。fit方法对输入的向量进行聚类,并返回每个样本所属的簇标签。try:定义了一个 POST 请求的 API 路由,路径为。

AI的内部世界的博客 1070

PAT 1060 爱丁顿数 (25分) (python 3)

英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。 输入格式: 输入第一行给出一个正整数 N (≤10​5​​),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车距离。 输出格式: 在一行中给出 ...

qq_46258819的博客 432

飞行机械臂设计

其后对飞行机械臂系统的机 理模型和基于 ADAMS 的物理模型进行了控制系统的搭建,对于机理模 型,设计了三个输入通道,分别是俯仰力矩,翻滚力矩与偏航力矩,控 制量为翻滚角,俯仰角,偏航角。四旋翼无人机自身具有独特的优势,在无人机上增加机械臂,整个 机体系统相当于一架空中行动自如的空中机器人,可以适应更多的应用场合,能够实现空中抓取,运输载荷,巡航监视等任务。的函数模块如图 4-8 所示,可见输入为 U1,U2,U3,U4,分别对应总力矩,俯仰力矩,翻滚力矩,偏航力矩,控制 量为俯仰角,翻滚角,偏航角。

coldmood77的博客 2965

FAA和EASA在机载电子硬件适航中的发展历史与差异

FAA和EASA在机载电子硬件的适航审查中虽然存在一些差异,但通过近年来的合作,这些差异正在逐步缩小。两者通过。

qq_41854911的博客 758

PTA 1068 万绿丛中一点红 Python实现 无超时

用Python实现的,没有超时,二维表,一次遍历

m0_68001632的博客 248

37、基于视觉的轻量级面部呼吸和心率测量技术

本文提出了一种基于视觉的轻量级面部呼吸和心率测量技术,通过远程光电容积脉搏波描记法(RPPG)和面部振动信息实现非接触式生理信号采集。创新性地结合框选和特征点选择多个感兴趣区域(ROI),并采用光流跟踪、主成分分析(PCA)和集成经验模态分解(EEMD)等方法优化信号处理流程。实验结果表明,该方法在测量精度和稳定性方面优于传统方法,并可在树莓派4等低功耗平台上实现实时运行,具有广泛的应用前景。

r7s8t的博客 312

PAT 1060 爱丁顿数(满分题解Python)

英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。输入第一行给出一个正整数 N (≤10^{5}​),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车距离。在一行中给出 N 天的爱丁顿数。6。

2401_83134679的博客 311

深度学习工具包 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")

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

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

用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

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

PTA 1060 爱丁顿数(Python3)

PAT (Basic Level) Practice (中文)

weixin_55730361的博客 325

PAT乙级 1060 爱丁顿数

题目: 输入样例: 10 6 7 6 9 3 10 8 2 7 8 输出样例: 6 法一: Python n = int(input()) num = [int(x) for x in input().split()] for i in range(n, -1, -1): m = n - i flag = 1 cnt = 0 for j in range(n)...

chongchujianghu3的博客 303

PAT乙级1060.爱丁顿数-(python)map,list,sort函数

文章目录前言1. 题目2. 三个python内置函数2.1 map()方法2.2 list()方法2.3 List.sort()方法3. 代码 前言 这个题,再介绍几个python内置函数。 1. 题目 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的...

ningzian的博客 580

PAT 1060 爱丁顿数 python

1060 爱丁顿数 (25 分) 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。 输入格式: 输入第一行给出一个正整数 N (≤10​5​​),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车...

Raaay的博客 477

PAT basic 1060

#include <cstdio> #include <algorithm> using namespace std; int a[1000000]; bool cmp1(int a, int b) { return a > b; } int main() { int n; scanf("%d", &n); for(int i = 1; i <= n; i++) {

Arthur_Holmes的博客 427

PTA 1060 爱丁顿数

题目如下 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。 输入格式: 输入第一行给出一个正整数 N (≤10​5),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车距离。 输出格式: 在...

LeRezz的博客 296

1060 爱丁顿数 (25分)

1060 爱丁顿数 (25分) 题目描述 : -------------------------------------------------------------------------------------------------------------------------------------- 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的

均瑶味动力的博客 275

PTA乙级题 1060 爱丁顿数

1060 爱丁顿数 (25 分) 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N)。 输入格式: 输入第一行给出一个正整数 N (≤10​5​​),即连续骑车的天数;第二行给出 N 个非负整数,代表每...

red_red_red的博客 466

[Python](PAT)1060 Are They Equal(25 分)

If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10​5​​ with simple chopping. Now given the number of signif...

贰拾壹 433

1060. 爱丁顿数(25) python篇

1060. 爱丁顿数(25) 时间限制 250 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数”E,即满足有E天骑车超过E英里的最大整数E。据说爱丁顿自己

zjw_python的博客 737

(python3)1060.爱丁顿数(25 分)

题目叙述如下:英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数” E ,即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤)。输入格式:输入第一行给出一个正整数 N (≤ 10^5),即连续骑车的天数;第二行给出 N 个非负整数,代表每天的骑车距离。输出格式:在一行中给出 ...

xutiantian1412的博客 712
上一篇: 用python来解 PAT 1050螺旋矩阵-25-满分无超时
下一篇: 用python来解 PAT 1061判断题-15-满分无超时
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址