浙大PTA 第4章-30 找完数 (20 分)

PTA 浙大版《C语言程序设计(第3版)》题目集全套代码 PTA 浙大版《C语言程序设计(第3版)》题目集全套代码 Here is PTA网站地址 本文适合C语言初学者,风格轻松明快,语言简洁易懂。本文在实际 案例中插入知识点,因为C语言不是学会的,而是练会的。多做题, 多上手写代码才能早日晋级,离开新手村。 来吧!投入C语言的怀抱吧! 文章目录PTA 浙大版《C语言程序设计(第3版)》题目集全套代码前前言 怎样算是一个好的程序前言一、函数题1.练习5-1 求m到n之和2.找两个数中最大者二、编程题1.练习2-1 Programming in C is fun 阅读详情

全题解析链接

浙大Python题目集 PTA95题全部解析


所谓完数就是该数恰好等于除自身外的因子之和。例如:6=1+2+3,其中1、2、3为6的因子。本题要求编写程序,找出任意两正整数m和n之间的所有完数。

输入格式:

输入在一行中给出2个正整数m和n(1<m≤n≤10000),中间以空格分隔。

输出格式:

逐行输出给定范围内每个完数的因子累加形式的分解式,每个完数占一行,格式为“完数 = 因子1 + 因子2 + ... + 因子k”,其中完数和因子均按递增顺序给出。若区间内没有完数,则输出“None”。

输入样例:

2 30

输出样例:

6 = 1 + 2 + 3
28 = 1 + 2 + 4 + 7 + 14

题解:

m,n=map(int,input().split())
flag = False
for i in range(m,n+1):
    sum = 1
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            sum+=j
            if j**2!=i:
                sum+=i//j
    if sum==i:
        flag = True
        print(f'{i} = 1',end='')
        li = []
        for j in range(2,int(i**0.5)+1):
            if i%j==0:
                print(f' + {j}',end='')
             
浙大PTA OJ漏洞 对PTA测试网站高危漏洞可以导致任意用户代码曝光的测试报告, 1.打开PTA提交列表,进行抓包: 发现使用Ajax获取了提交列表,查看有getSubmitList项: http://pta.patest.cn/api/exam/getSubmitList?limit=50&offset=0&hasTotal=true&order=&tId=56&userName=&timestamp 阅读详情

相关推荐

【Python基础】PTA浙大版《Python程序设计》题目集题解 (一)

这个系列的博客主要内容是PTA中浙大版的《Python程序设计》题目集的所有题解,共同89道编程题和6道函数题,帮助初学者快速上手做题。由于题量过大,我会分成几个小块发表。 本博客为该系列的第一篇博客,主要内容为编程题的第一章3道题以及第二章的1-8题题解,后续会持续更新。 PTA浙大版《Python程序设计》题目集题解(一)1.第1章-1 从键盘输入两个数,求它们的和并输出2.第1章-2 从键盘输入三个数到a,b,c中,按公式值输出3.第1章-3 输出“人生苦短,我学Python”4.第2章-1 计算 .

weixin_51424157的博客 6503

PTA 陈越 数据结构习题 6-1 单链表逆转 (20分)

浙大PTA 数据结构习题 6-1 单链表逆转 (20分) 本题要求实现一个函数,将给定的单链表逆转。 函数接口定义: List Reverse( List L ); 其中List结构定义如下: typedef struct Node PtrToNode; struct Node { ElementType Data; / 存储结点数据 / PtrToNode Next; / 指向下一个结点的指...

AKAPinkman的博客 4990

AD学习笔记(一)基础认识

文章目录AD学习笔记第一讲 AD基础认识一、两库两图(分别对应下图)1、PCB图(pcbdoc)2、原理图(schdoc)3、原理图库(schlib)4、PCB库(pcblib)二、封装1、DIP封装2、LQFP封装三、绘制整体流程1、建立工程(PrjPcb)2、建立两库两图并保存整个工程(五次)3、从库中提取绘制原理图4、原理图导入pcb图5、根据原理图布线6、pcb图交由工厂打板 AD学习笔记 第一讲 AD基础认识 一、两库两图(分别对应下图) PCB图(pcbdoc) 原理图(schdoc) PCB库

qq_52465473的博客 6689

超详细!新手必看STM32-DMA配置与实验(串口使用DMA发送数据)

DMA就是:直接存储器访问。DMA传输数据从一个地址空间复制到另一个地址空间,提供在外设和存储器或者存储器和存储器之间的高速数据传输。

qq_1033275663的博客 2万+

512分辨率万能遮罩模型实战指南:从下载到高精度应用

本文提供了512分辨率万能遮罩模型的完整实战指南。该模型经过超过540万次迭代,专门优化了对头发、手、眼睛等复杂区域的识别。文章详细介绍了从可靠渠道下载、环境部署、使用DF_ICE工具批量应用遮罩,到利用XSeg Editor进行高精度精修的全流程,旨在帮助用户显著提升AI换脸合成视频的质量与效率。

y2z3a4b5c的博客 1176

17【Protues单片机仿真】基于51单片机的太阳能智能谷物翻晒机器人

基于51单片机,避障,低于50CM报警,LED灯亮起,自动翻晒用光敏电阻,光照强度大,电机转动,相当于翻晒粮食,远程控制用按键代替,按下去电机就转动,相当于翻晒粮食,然后光照强度和超声波的距离都在LCD1602显示屏显示出来。

weixin_70360261的博客 1453

【python股票价格预测】基于LSTM(长短期记忆网络)的股票价格预测(附python代码)

【python股票价格预测】基于LSTM(长短期记忆网络)的股票价格预测(附python代码)

k8291121的博客 1017

Redhawk: dynamic ir drop分析(Clock Buffer Clustering)

在dynamic分析中,ir drop问题多出现在三种情况下,缺power mesh,缺power switch,clock cell过于密集。 前两种情况通过选中具体instance查看min res path都比较容易分析出来,而且大部分问题都出现在channel里,这里不多做赘述。 clock cell过于密集这是观察结果,缺少报告支持,这里分享一下分析方法。 首先,选中压降超过signoff标准的instance,(Results->List of Worst Instance DVD中

m0_61544122的博客 5288

Python 爬虫实战:抓取新闻网站上的新闻标题和内容

随着信息化的进展,新闻网站已经成为人们获取新闻和时事资讯的主要途径。许多新闻网站提供了丰富的内容,涵盖了社会、政治、科技、娱乐等多个领域。通过抓取新闻网站的内容,我们可以分析新闻的趋势,获取某一领域的最新动态,甚至为数据分析和机器学习提供数据支持。本文将详细介绍如何使用 Python 编写爬虫,抓取新闻网站上的新闻标题和内容。requests:发送 HTTP 请求,获取页面内容。:解析 HTML 页面并提取数据。Selenium:抓取动态加载的网页内容。新闻API。

2201_76125261的博客 3412

Codex 实战 Skills:编写 Skill 自动为 ESP32 芯片生成 MQTT 订阅与发布的基础代码

为了更清晰地展示 Skill 的工作原理和两种语言的差异,以下提供原理图和比对表格。本文深入探讨了如何利用 Codex 的 Agent 智能体技能(Skills)自动化 ESP32 与 MQTT 通信的代码生成过程。我们首先分析了 IoT 开发的痛点,然后详细设计了 Skill 的输入配置,并分别提供了 MicroPython 和 C++ 两种语言的完整代码实现。通过对比两种语言的优缺点,帮助开发者根据项目需求选择合适的语言。最后,我们提供了详细的运行指南,确保开发者能够快速上手。Skill 设计哲学。

yueyeguzhuo的专栏 87

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

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

上一篇: 浙大PTA 第4章-29 找出不是两个数组共有的元素 (20 分)
下一篇: 浙大PTA 第5章-1 输出星期名缩写 (70 分)
amateur_python
博客等级 码龄5年 121粉丝 94原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址