华为OD机试 - 数据最节约的备份方法 - 贪心算法、FFD算法(Java 2025 B卷 100分)

一、题目描述

有若干个文件,使用刻录光盘的方式进行备份,假设每张光盘的容量是500MB。

求使用光盘最少的文件分布方式,所有文件的大小都是整数的MB,且不超过500MB,文件不能分隔、分卷打包。

二、输入描述

每组文件大小的数据。

三、输出描述

使用光盘的数量。

四、测试用例

测试用例1

1、输入

100 200 100

2、输出

1

3、输出

总大小400MB < 500MB,一张光盘可以装下所有文件

测试用例2

1、输入

400 100 200 300 100

2、输出

3

3、输出

排序后:[400, 300, 200, 100, 100]
第1张光盘:400MB,剩余100MB
第2张光盘:300MB,剩余200MB
第2张光盘:放入200MB,剩余0MB
第1张光盘:放入100MB,剩余0MB
第3张光盘:100MB,剩余400MB

【100分】 【数据最节约的备份方法】 这道题目要求使用刻录光盘的方式对若干个文件进行备份,每张光盘的容量为500MB。需要计算使用光盘最少的文件分布方式,保证所有文件的大小都是整数的MB,且不超过500MB,文件不能分割、分卷打包。有若干个文件,使用刻录光盘的方式进行备份,假设每张光盘的容量是500MB,求使用光盘最少的文件分布方式。以上就是解决这个问题的主要思路和算法步骤。在代码中,我保留了原有的中文注释,使得代码更易于理解。所有文件的大小都是整数的MB,且不超过500MB;文件不能分割、分卷打包。为了解决这个问题,我们可以使用回溯算法。 阅读详情

相关推荐

数据最节约的备份方法

已支持(Java & JS & Python & C),实现:二分法 + 回溯算法

CSDN 4861

【python实现华为OD机试真题】数据最节约的备份方法【2023 Q2 | 100分】

有若干个文件,使用刻录光盘的方式进行备份,假设每张光盘的容量是500MB,求使用光盘最少的文件分布方式所有文件的大小都是整数的MB,且不超过500MB;文件不能分割、分卷打包。输入输出示例仅供调试,后台判题数据一般不包含示例。

flying meng的菜鸟居 642

【100%通过率】华为od统一考试B卷【数据最节约的备份方法】C语言 实现

有若干个文件,使用刻录光盘的方式进行备份,假设每张光盘的容量是500MB.求使用光盘最少的文件分布方式所有文件的大小都是整数的MB,且不超过500MB:文件不能分割、分卷打包

MISAYAONE的博客 434

2023年华为od机试 Java【刻录光盘备份】

有一系列文件需要通过光盘备份。每张光盘的容量固定为500MB,文件的大小均为整数MB并且不超过500MB。文件不可拆分或分卷备份。需要确定最少需要多少张光盘来完成备份。(100,400),(200,300),(500) 3张光盘即可,输入和输出内容都不含空格。

wtswts1232的博客 965

光盘刻录工具中文版的

很好的光盘刻录工具,ExploreBurnSetup.exe 我用了很不错的

一份光盘刻录程序的代码

一份光盘刻录程序的代码,有清楚的scsi指令方案。非常值得学习哦

正点原子ATK-LORA-01无线串口代码移植+STM32F103C8T6(标准库)

目录 一、ATK-LORA-01无线串口资料 二、代码移植 1.分析 (1)usart3(也可以是其他的串口)用于接收数据的串口 usart.h (2)time3(也可以是其他的定时器)用于时序的设置 (3)lora.c 三、演示 1.主机(发送方) (1)主机接线 (2)主机代码(发送方) (3)主机实物 插上无线串口通电即可发送​ 2.从机(接收方) (1)从机接线(LORA与主机相同) (2)从机代码(接收方) (3)从机实物 接上TTL和LORA并通电即...

m0_56942354的博客 8973

高光谱盲超分DBSR复现全记录:从退化估计到双域耦合的工程实践

高光谱图像超分辨率旨在从低分辨率观测中恢复高分辨率光谱立方体,其核心挑战在于退化过程未知,即盲超分问题。盲超分需同时估计模糊核、噪声水平与下采样方式,本质上是病态逆问题,依赖空间与光谱先验约束。双域耦合方法通过联合空间域与光谱域信息,显著提升退化核估计精度与光谱保真度,技术价值在于更贴近真实成像场景。该技术广泛应用于遥感、医学影像与材料检测等领域。本文围绕DBSR(双域盲超分)的复现,深入剖析退化估计子网调试、双域主干训练策略及显存优化等工程细节,为高光谱盲超分实践提供可复现的参考。

weixin_29031057的博客 205

Codex 命令行高效操作指南

本文详细介绍了Codex命令行工具的高效使用方法,包括安装配置、核心参数解析和实战技巧。通过`codex complete`、`codex explain`等指令,开发者可以快速生成代码、调试错误和重构项目,显著提升开发效率。特别推荐使用`--temperature`和`--max-tokens`参数优化生成结果。

weixin_29201313的博客 536

海康工业相机使用教程

海康工业相机连接电脑教程

qq_43251445的博客 2万+

Label Studio 数据标注平台,大模型预训练与微调必备

摘要:LabelStudio是一款开源数据标注工具,支持文本、图像等多种数据类型的标注。本文介绍了其安装方法(通过conda创建环境并pip安装)、基础使用流程(创建项目、导入数据、设置标签、标注导出)以及AI自动标注功能的实现。重点讲解了如何通过MLBackend集成LangChain模型实现自动标注:创建自定义模型类、构建预测链、处理返回结果,最后配置到LabelStudio项目中。该功能可显著提升标注效率,标注人员只需在AI预测结果基础上进行修正。

技术引领业务创新 291

新能源汽车动力总成研发测试技术全景深度报告(2025版)

本文所有企业案例数据均来自上市公司财报、工信部备案信息及权威媒体报道,技术参数经第三方检测报告交叉验证。研发测试人员能力矩阵重构(T型人才进阶路径)[10] 全球动力总成市场2035年预测报告。[9] NI电动汽车HIL测试架构技术文档。[3] 东风汽车智能化研发体系深度报告。[5] 混合动力测功机发明专利技术细节。[1] 领克动力总成试验中心技术解析。[7] 新能源汽车产业迭代趋势白皮书。测试架构师-数字工程。测试架构师-安全合规。测试架构师-人工智能。

CSDN-新能源汽车研发测试专业博主 787

SAP 调用Ftp服务器

FTP(File transfer protocol)是一种标准的网络协议,可以用于在互联网上传递文件。SAP系统中可通过系列配置和提供的些标准函数,用于查看、更新、下载FTP服务器上的文件。提示:以下是本篇文章正文内容,下面案例可供参考。

qq_38304013的博客 1418

RT-DETR改进策略【卷积层】| ECCV-2024 小波卷积WTConv 增大感受野,降低参数量计算量,独家创新助力涨点

本文记录的是利用模块优化的目标检测网络模型。的目的是在不出现过参数化的情况下有效地增加卷积的感受野,从而解决了在感受野扩展中的参数膨胀问题。本文将其加入到深度可分离卷积中,有效降低模型参数量和计算量,并二次创新,使模块更好地捕捉低频特征,增强网络性能。Wavelet Convolutions for Large Receptive Fields小波卷积及其改进的实现代码如下: 四、创新模块 4.1 改进点1⭐ 模块改进方法:加入(第五节讲解添加步骤)。添加后如下:模块改进方法:基于的(第五节讲解添加步骤)

Limiiiing的博客 1509

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

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

上一篇: 华为OD机试 - 最长连续子序列 - 双指针(Java 2025 B卷 100分)
下一篇: 华为OD机试 - 查找众数及中位数(Java 2025 C卷 100分)
哪 吒
哪 吒 2022年度博客之星TOP 1 2022年度博客之星TOP 1 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄9年 59万+粉丝 2962原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哪 吒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址