联合省选 2021 解题报告

2021年美赛E题 2021年美赛E题翻译2021年美赛E题翻译解题思路 2021年美赛E题翻译 2021 ICM 问题E:重新优化食品系统 最近发生的事件向我们表明,即使在全球部分地区,我们的全球粮食系统也是不稳定的普遍运作良好的世界。这些不稳定部分是由于我们当前的全球大规模的国家和国际食品生产和分配系统。这个食物系统允许相对便宜和有效地生产和分配食物,因此建议当前模型优先考虑效率和获利能力。 尽管该系统效率很高,但联合国估计仍有8.21亿人世界各地都饱受饥饿之苦[1],即使有足够的食物来满足每一个全世界的人。[2]粮食不安 阅读详情

很久没有写过博客了呢。

D1T1 - 卡牌游戏

Alice 有 n n n 张卡牌,第 i i i( 1 ≤ i ≤ n 1 \le i \le n 1≤i≤n)张卡牌的正面有数字 a i a_i ai​,背面有数字 b i b_i bi​,初始时所有卡牌正面朝上。

现在 Alice 可以将不超过 m m m 张卡牌翻面,即由正面朝上改为背面朝上。Alice 的目标是让最终朝上的 n n n 个数字的极差(最大值与最小值的差)尽量小。请你帮 Alice 算一算极差的最小值是多少。

对于数字考虑,极差最小就是对于排序之后的数组中,取一个长度最短的区间。

我们把 a i a_i ai​ 和 b i b_i bi​ 都放进去排序,取 n n n 张牌至少出现一次且反面向上的不超过 m m m 张的区间。这很好维护,也不难证明左端点移动时,右端点是单调的,因此用双指针维护即可。

时间复杂度 O ( n ) \mathcal{O}(n) O(n).

D1T2 - 矩阵游戏

Alice 有一个 n × m n \times m n×m 的矩阵 a i , j a_{i, j} ai,j​( 1 ≤ i ≤ n 1 \le i \le n 1≤i≤n, 1 ≤ j ≤ m 1 \le j \le m 1≤j≤m),其每个元素为大小不超过 10 6 {10}^6 106 的非负整数。

Bob 根据该矩阵生成了一个 ( n − 1 ) × ( m − 1 ) (n - 1) \times (m - 1) (n−1)×(m−1) 的矩阵 b i , j b_{i, j} bi,j​( 1 ≤ i ≤ n − 1 1 \le i \le n - 1 1≤i≤n−1, 1 ≤ j ≤ m − 1 1 \le j \le m - 1 1≤j≤m−1),每个元素的生成公式为

b i , j = a i , j + a i , j + 1 + a i + 1 , j + a i + 1 , j + 1 b_{i, j} = a_{i, j} + a_{i, j + 1} + a_{i + 1, j} + a_{i + 1, j + 1} bi,j​=ai,j​+ai,j+1​+ai+1,j​+ai+1,j+1​

现在 Alice 忘记了矩阵 a i , j a_{i, j} ai,j​,请你根据 Bob 给出的矩阵 b i , j b_{i, j} bi,j​ 还原出 a i , j a_{i, j} ai,j​。

直接高斯消元可以获得一组没有限制的可行解。

首先我们考虑 a i , j a_{i,j} ai,j​ 范围没有限制的时候怎么做。

那就把第 1 行和第 1 列都定为 0 去递推就好了,反正一定有解,根本不要什么高斯消元。

那么我们就要考虑怎么把这组可行解的值都塞进 [ 0 , 1 0 6 ] [0,10^6] [0,106] 以内。

考虑将矩阵的一行加上 ⟨ − k , k , − k , … , ( − 1 ) j ⋅ k , … , ( − 1 ) m ⋅ k   ⟩ \left\langle -k,k,-k,\ldots,(-1)^j\cdot k,\ldots, (-1)^m\cdot k\ \right\rangle ⟨−k,k,−k,…,(−1)j⋅k,…,(−1)m⋅k ⟩,那么显然 b b b 不会发生改变,因为受到影响的四格中必然一格加一格减。列同理。

所以我们可以将元素 a i , j ′ a'_{i,j} ai,j′​ 调整为 a i , j = a i , j ′ + ( − 1 ) j ⋅ p i + ( − 1 ) i ⋅ q j a_{i,j}=a'_{i,j}+(-1)^j\cdot p_i+(-1)^i\cdot q_j ai,j​=ai,j′​+(−1)j⋅pi​+(−1)i⋅qj​,那么只要 a i , j ∈ [ 0 , 1 0 6 ] a_{i,j}\in[0,10^6] ai,j​∈[0,106],即

− a i , j ′ < ( − 1 ) j ⋅ p i + ( − 1 ) i ⋅ q j < 1 0 6 − a i , j ′ -a'_{i,j}<\quad (-1)^j\cdot p_i+(-1)^i\cdot q_j\quad <10^6-a'_{i,j} −ai,j′​<(−1)j⋅pi​+(−1)i⋅qj​<106−ai,j′​

考虑解不等式的一边,那么就很显然是一个差分约束问题……好像哪里不对劲。

如果 p i p_i pi​ 和 q j q_j qj​ 同号,也就是 i , j i,j i,j 奇偶性相同就没有办法做了。明明长得就是个差分约束的样子,却又不能做。于是做到这我自闭了……

于是就学习了一个新的技巧。

我们令 c i = ( − 1 ) i ⋅ p i , d j = ( − 1 ) j + 1 ⋅ q j c_i=(-1)^i\cdot p_i, d_j=(-1)^{j+1}\cdot q_j ci​=(−1)i⋅pi​,dj​=(−1)j+1⋅qj​,则

( − 1 ) j ⋅ p i + ( − 1 ) i ⋅ q j = ( − 1 ) i + j ⋅ c i + ( − 1 ) i + j + 1 ⋅ d j \begin{matrix}(-1)^j\cdot p_i+(-1)^i\cdot q_j&=&(-1)^{i+j}\cdot c_i+(-1)^{i+j+1}\cdot d_j\end{matrix} (−1)

2021.05.25 XCTF入门RE | CTF - RE 样本编译方式CPython南邮Py.pyc C Python 支持所有Python版本的Pyc反编译工具(在线) 或者下载pyc的反编译工具uncompyle6 南邮Py.pyc 反编译后的源码为: import base64 def encode(message): s = '' for i in message: x = ord(i) ^ 32 x = x + 16 s += chr(x) return base64.b64en 阅读详情

相关推荐

乳腺癌预测的数学建模与机器学习研究:以2021D题为例

研究生数学建模竞赛是锻炼研究生数学建模能力的重要平台。通过对实际问题的数学建模和求解,可以提高研究生运用数学工具解决实际问题的能力,同时也培养了研究生的团队协作和创新思维能力。数学建模竞赛的起源可以追溯到20世纪70年代末至80年代初的美国,最初是由数学家和工程师为了解决实际问题而进行的活动。他们试图通过建立数学模型来描述现实世界中的复杂系统,并以此作为工具预测系统未来行为或优化系统设计。随着数学工具的发展和应用需求的增加,数学建模竞赛逐步形成了一套较为完整的竞赛体系。

weixin_36204513的博客 1324

如何下载最新版本的VMware Workstation

随着虚拟化技术的发展,VMware Workstation作为行业领先的桌面虚拟化软件,为用户提供了在单一物理计算机上运行多个操作系统的能力。本文将详细介绍如何从Broadcom支持网站下载最新的VMware Workstation Pro版本。

安呀智数据坊的博客 681

HFSS螺旋线圈的设计与仿真

undefined.全局变量在这里进行设置:Project/Project Properties, browse and setup the global variables.undefined.方程中的局部变量设置:HFSS/Design Properties, browse and setup the local variables。按照下图填写曲线的方程内容:fill the parameters according to the setup in the following picture。

johnboat的专栏 3852

Android音频学习(八)——AudioFlinger线程

在 PlaybackThread 的实现中,Flag 用于标识线程的特殊行为或配置。

miemie2014的博客 1410

FastAPI + React:现代 Web 前后端分离开发的全栈实践指南

• 部署:CI/CD 双流水线,前端 push → GitHub Actions → Cloudflare Pages;• 后端:分层结构 routers → services → repositories → models,单测覆盖率 90 %。• 接口缓存:Redis + FastAPI Depends 实现接口级缓存,读 QPS 提升至 5 k。• 前端:BFF 由 React Query 代理,统一缓存、重试、分页。GET /items/{id} 详情。,前端同学无需等 Mock 即可联调。

未来已来,AI时代,学AI编程,做AI量化,就来大鹏AI教育。 1504

JSON 与 JSON-RPC 的区别

JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,基于文本,采用人类可读的语法来表示结构化数据。它起源于JavaScript,但如今已被几乎所有主流编程语言支持。标准文档:RFC 4627数据类型:支持 String、Number、Boolean、Null、Object、Array 六种基本类型格式示例"name": "张三","age": 30,JSON-RPC(JSON Remote Procedure Call)是一种远程过程调用(RPC)协议。

h a 6 6 6 c k 为 你解决复杂难题! 154

STM32(HAL库)驱动OLED

通过STM32F103C8T6单片机采用HAL库方式对0.96寸OLED(IIC通讯)屏幕进行驱动。

weixin_44597885的博客 8815

运维系列【仅供参考】: Windos10和Windos11 配置intel网卡vlan的方法

Windos10和Windos11 配置intel网卡vlan的方法

weixin_54626591的博客 482

易盾滑块的js逆向分析

基于易盾的滑块验证码进行逆向分析,最种实现全系列的验证码逆向,包括滑块、点选、推理拼图等多种类型。

shanf7921的博客 3万+

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

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

上一篇: APIO2020游记
下一篇: 数据结构8——无旋Treap
frankchenfu
博客等级 码龄9年 9粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址