2021牛客多校第二场 A——Arithmetic Progression

网易2018校招编程题集合2 如果一个数列S满足对于所有的合法的i,都有S[i + 1] = S[i] + d, 这里的d也可以是负数和零,我们就称数列S为等差数列。 小易现在有一个长度为n的数列x,小易想把x变为一个等差数列。小易允许在数列上做交换任意两个位置的数值的操作,并且交换操作允许交换多次。但是有些数列通过交换还是不能变成等差数列,小易需要判别一个数列是否能通过交换操作变成等差数列  输入描述: 输入包 阅读详情

题目大意

给你一个长度为 nnn 的数列 aaa ,数列中每个元素都不一样,问你存在多少个区间,这些区间内的数排序后是一个等差数列

解题思路

对于一个区间,如果这个区间内的数排序后的元素可以构成一个等差序列,那么一定满足下列性质
max−min=(r−l)×gcdmax - min = (r - l) \times gcdmax−min=(r−l)×gcd
其中 gcdgcdgcd 是区间差分绝对值的最大公约数
minminmin 是区间的最小值
maxmaxmax 是区间的最大值
我们做这题的思想是,枚举右端点,用数据结构维护有多少个合法的左端点
我们用一个线段树来维护这个东西。线段树一个节点维护四个值
dat:max−min−(r−l)×gcddat: max-min-(r-l)\times gcddat:max−min−(r−l)×gcd的最小值,右端点为我们枚举的右端点(因为这个式子的最小值为0,当这个值为0时,说明这是一个合法的区间)
cnt:cnt:cnt:合法左端点的个数
add:add:add:懒标记
g:g:g:当前节点所代表区间的差分的绝对值的最大公约数
这样我们每次询问区间 [1,r][1, r][1,r] 就可以知道有多少个合法的区间

接下来我们考虑右端点往右移(即新加一个数)的情况。
新加入一个数,可能对之前的 minminmin 和 maxmaxmax 有影响,为了解决这个问题,我们用单调栈解决。

我们对于 minminmin 维护一个上升的单调栈,栈里面存下标
如果新加入的元素比栈顶大,那么直接入栈,它不会对之前区间的 minminmin 产生影响。
如果新加入的元素小于等于栈顶元素,那么我们将区间 [[[ 栈顶第二个元素+1, 栈顶元素 ]]] 都加上栈顶元素下标所在的值(这一步是为了消除栈顶元素的影响)
弹出栈顶元素,直到当前元素比栈顶元素大,否则一直执行上述步骤。
然后将区间 [[[栈顶元素+1, 当前枚举的右端点 ]]] 减去当前元素(这一步是为了加上这新元素的影响)
对于 maxmaxmax 维护一个下降的单调栈,与上述操作类似,不再赘述。

我们维护完了最大最小值,我们再维护 (r−l)×gcd(r-l)\times gcd(r−l)×gcd。我们记 d=∣ai−1−ai∣d = |a_{i-1} - a_i|d=∣ai−1​−ai​∣,我们更新区间 [1,r−1][1, r-1][1,r−1]

当区间的 ggg 满足 g!=0&& d∣gg != 0 \&\& \ d|gg!=0&& d∣g时,说明这个区间新加入这个数是能维持 ggg 不变的,所以我们新加入一个数的影响是将这个区间的值减去一个 ggg (因为区间长度变长了,所以要减去一个 ggg 如果不懂再看看 datdatdat 的定义)
如果不满足上述条件,我们需要将之间的(r−l)∗g(r-l) * g(r−l)∗g加上(消去之前的影响),再将 g=gcd(g,d)g = gcd(g, d)g=gcd(g,d),然后减去(r−l)∗g(r-l) * g(r−l)∗g,(加上这个数的影响)

Code

#include <bits/stdc++.h>
#define ll long long
#define qc ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define pb push_back
using namespace std;
const int MAXN = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int n;
int stmi[MAXN], stma[MAXN];
ll a[MAXN];
ll gcd(ll a, ll b){
	return b ? gcd(b, a%b) : a;
}
struct Tree{
	int l, r;
	ll dat, g, add, cnt;
}tree[MAXN << 2];
void pushup(int rt){
	tree[rt].cnt = 0;
	tree[rt].dat = min(tree[rt << 1].dat, tree[rt << 1 | 1].dat);
	if(tree[rt].dat == tree[rt << 1].dat)
		tree[rt].cnt += tree[rt << 1].cnt;
	if(tree[rt].dat == tree[rt << 1 | 1].dat)
		tree[rt].cnt += tree[rt << 1 | 1].cnt;
	if(tree[rt << 1].g && tree[rt << 1 | 1].g && tree[rt << 1].g == tree[rt << 1 | 1].g)
		tree[rt].g = tree[rt << 1].g;
	else
		tree[rt].g = 0;
}
void build(int l, int r, int rt){
	tree[rt].l = l;
	tree[rt].r = r;
	tree[rt].cnt = tree[rt].add = tree[rt].g = tree[rt].dat = 0ll;
	if(l == r){
		tree[rt].cnt = 1ll;
		return ;
	}
	int m = (l + r) >> 1;
	build(l, m, rt << 1);
	build(m+1, r, rt << 1 | 1);
	pushup(rt);
}
void pushdown(int rt){
	if(tree[rt].add){
		tree[rt << 1].dat += tree[rt].add;
		tree[rt << 1].add += tree[rt].add;
		tree[rt << 1 | 1].dat += tree[rt].add;
		tree[rt << 1 | 1].add += tree[rt].add;
		tree[rt].add = 0;
	}
}
void update(int L, int R, ll val, int rt){
	if(L <= tree[rt].l && tree[rt].r <= R){
		tree[rt].dat += val ;
		tree[rt].add += val;
		return;
	}
	pushdown(rt);
	int m = (tree[rt].l + tree[rt].r) >> 1;
	if(L <= m)
		update(L, R, val, rt << 1);
	if(m < R)
		update(L, R, val, rt << 1 | 1);
	pushup(rt);
}
void updateGcd(int R, int l, int r, ll g, int rt){
	if(l <= tree[rt].l && tree[rt].r <= r && tree[rt].g && g % tree[rt].g == 0){
			tree[rt].dat -= tree[rt].g;
			tree[rt].add -= tree[rt].g;
	}
	else if (tree[rt].l == tree[rt].r){
			tree[rt].dat += (R - tree[rt].l - 1) * tree[rt].g;
			tree[rt].add += (R - tree[rt].l - 1) * tree[rt].g;
			tree[rt].g = gcd(g, tree[rt].g);
			tree[rt].dat -= (R - tree[rt].l) * tree[rt].g;
			tree[rt].add -= (R - tree[rt].l) * tree[rt].g;
	}
	else{
		pushdown(rt);
		int m = (tree[rt].l + tree[rt].r) >> 1;
		if(l <= m)
			updateGcd(R, l, r, g, rt << 1);
		if(m < r)
			updateGcd(R, l, r, g, rt << 1 | 1);
		pushup(rt);
	}
	
}
ll query(int L, int R, int rt){
	if(L <= tree[rt].l && tree[rt].r <= R){
		return tree[rt].dat == 0 ? tree[rt].cnt : 0;
	}
	pushdown(rt);
	int m = (tree[rt].l + tree[rt].r) >> 1;
	ll ret = 0;
	if(L <= m)
		ret += query(L, R, rt << 1);
	if(m < R)
		ret += query(L, R, rt << 1 | 1);
	return ret;
}
void solve(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
    	scanf("%lld", a+i);
    ll ans = 0;
    build(1, n, 1);
    int topmi = 0, topma = 0;
    for(int i = 1; i <= n; i++){
    	while(topmi && a[stmi[topmi]] > a[i]){
    		update(stmi[topmi - 1] + 1, stmi[topmi], a[stmi[topmi]], 1);
    		topmi--;
    	}
    	update(stmi[topmi] + 1, i, -a[i], 1);
    	stmi[++topmi] = i;
    	while(topma && a[stma[topma]] < a[i]){
    		update(stma[topma - 1] + 1, stma[topma], -a[stma[topma]], 1);
    		topma--;
    	}
    	update(stma[topma] + 1, i, a[i], 1);
    	stma[++topma] = i;
    	if(i != 1){
    		updateGcd(i, 1, i-1, abs(a[i] - a[i-1]), 1);
    	}
    	ans += query(1, i, 1);
    }
    printf("%lld\n",ans);
}

int main()
{
	#ifdef ONLINE_JUDGE
    #else
       freopen("in.txt", "r", stdin);
       freopen("out.txt", "w", stdout);
    #endif

	// qc;
    int T;
    // cin >> T;
    scanf("%d",&T);
    // T = 1;
    while(T--){

        solve();
    }
	return 0;
}
别再只盯着MES了!半导体/面板厂CIM系统全家桶(EAP/YMS/SPC)保姆级入门指南 本文深入解析半导体制造中的CIM系统,涵盖EAP、YMS和SPC等关键子系统的协同工作。通过实战案例和技术细节,展示如何利用CIM系统提升生产效率、良率管理和设备维护,为半导体/面板厂提供全面的实施指南和优化策略。 阅读详情

相关推荐

腾讯WeKnora开源了!手把手教你用Docker+Ollama本地部署多模态知识库(附避坑指南)

本文详细介绍了腾讯开源的多模态知识库工具WeKnora的本地部署方法,通过Docker和Ollama实现完全离线运行。文章包含环境准备、核心组件配置、Ollama模型集成、系统启动验证及高级性能调优等实战内容,特别适合需要构建私有化知识库的中小团队和个人开发者。

weixin_30664051的博客 478

bzoj 4373: 算术天才⑨与等差数列

Description 算术天才⑨非常喜欢和等差数列玩耍。 有一天,他给了你一个长度为n的序列,其中第i个数为a[i]。 他想考考你,每次他会给出询问l,r,k,问区间[l,r]内的数从小到大排序后能否形成公差为k的等差数列。 当然,他还会不断修改其中的某一项。 为了不被他鄙视,你必须要快速并正确地回答完所有问题。 注意:只有一个数的数列也是等差数列。 Input 第一

lqybzx的专栏 1096

NCCL分布式训练中ibv_reg_mr_iova2内存分配失败的3种解决方案(附详细排查流程)

本文深入探讨了NCCL分布式训练中ibv_reg_mr_iova2内存分配失败的3种解决方案,包括快速临时修复、标准系统配置和PAM模块根治方案。详细分析了错误原因,提供了完整的排查流程和性能优化建议,帮助开发者高效解决RDMA网络环境下的内存锁定问题。

nut55的博客 625

n个整数中,找出尽可能多的数使他们组成一个等差数列,求最长等差数列的长度...

例子: 3,8,4,5,6,2 返回值应该为 :5 这是昨天做的一道优酷土豆的编程题,和leetcode中的128/Longest Consecutive Sequence 有点相似,但是leetcode题的公差是确定的1,而这道题的公差是不确定的。 本人的写出的是一种通过穷举的方法实现查找最长等差数列,通过hash使查找更为方便,减少了复杂度。 int ca...

weixin_34185560的博客 625

SpringBoot实战——仿b站项目(一)

热部署就是当应用程序这种运行的时候升级冉家或者修改某一部分代码、配置文件时,无需手动启动应用,即可修改的部分生效工具 + IDEA配置。

weixin_52880572的博客 3455

MATLAB射线追踪算法实战:从零搭建通信信号传播模型(附完整代码)

本文提供了一份详细的MATLAB射线追踪算法实战指南,指导读者从零开始搭建通信信号传播模型。内容涵盖场景建模、射线发射、路径追踪与信号计算等核心环节,并附有完整代码,帮助通信与电子工程领域的学习者和工程师快速掌握这一精确模拟电磁波传播的关键技术。

weixin_29092031的博客 196

【等差数列】题解

Link 给你一个长为 nnn,首项为 aaa,公差为 ddd 的等差数列。 从 xxx 中任选两个数 xi,xjx_i,x_jxi​,xj​ ,同时满足: xi+xjx_i+x_jxi​+xj​ 为偶数。 xxx 中没有 xi+xj2\frac{x_i+x_j}{2}2xi​+xj​​ 那么你就可以将 xi+xj2\frac{x_i+x_j}{2}2xi​+xj​​ 加入 xxx 中,称为一次操作。 注意:新加入的数也可被选择。 问你最多能进行几次操作? 蒟蒻第一次打月赛,激动地点开第一题:

qq_66589321的博客 705

R语言缺失值填补|插值法、均值法、邻近法

本文主要介绍如何利用R语言进行数值型缺失值的填补。主要使用zoo包中的na.aggregate() 、na.approx()、na.locf() 函数进行缺失值的均值填补、线性插值填补以及邻近值填补。

Mrrunsen的博客 3841

2018 河北省大学生程序设计竞赛

problem d:ch给你一个长度为n的数列,有两种操作:1.set  l  r  x :将[l,r]内的数全部赋值为x;2.query  l  r ;查询[l,r]中占主导地位的数字是哪个;该数字占主导地位指:该数在该区间中出现的此时占了区间长度的一半以上(出现一半不算占主导地位)。若没有,输出-1.input:第一行,一个数:n,表示序列的长度(1&lt;=n&lt;=200000);第二行...

Wild_Will的博客 3747

AIGC游戏本地化:用AI实现多语言自动翻译

游戏本地化是游戏全球化战略的关键环节,传统人工翻译方式成本高、周期长。本文旨在探讨如何利用AIGC技术实现高效、准确、低成本的游戏多语言自动翻译解决方案。我们将覆盖从文本翻译到语音合成的完整本地化流程,重点关注AI技术在游戏特定语境下的应用优化。文章首先介绍游戏本地化的核心挑战和AI解决方案,然后深入讲解关键技术原理,接着通过实战项目演示具体实现,最后讨论应用场景和未来趋势。AIGC:人工智能生成内容,指利用AI技术自动生成文本、图像、音频等内容本地化(Localization)

AI 领航者的博客 1337

uniapp:实现APP获取陀螺仪数据、加速传感器、线性加速传感器,uniApp实时监听陀螺仪【XYZ】数据及停止监听与资源释放等功能示例源码,根据需求做功能(完美兼容Android安卓、苹果ios)

uniapp陀螺仪,uniapp加速传感器,uniapp线性加速传感器,APP陀螺仪数据,uniapp app 端获取陀螺仪数据示例代码,手机中获取陀螺仪的数据,uniApp实时获取陀螺仪xyz数据,android陀螺仪方向,获得陀螺仪传感器,处理传感器数据,停止监听与资源释放,Android使用陀螺仪,uniapp苹果ios陀螺仪,uni-app设备之(加速计,罗盘,陀螺仪)插件安卓/IOS APP提供了获取陀螺仪数据的能力,手机陀螺仪传感器获得手机自身旋转的角度,陀螺仪获取旋转角度,陀螺仪、加速度传感器

✅ 精选推荐文章 4266

2021牛客暑假多校第二场部分题解

C-Draw Grids 题意:给你一个n*m的点矩阵,每次可以连相邻两个点的一条边,直到连完无法操作的时候就输了,前提是不能连成一个多边形。问你第一个人能不能赢 思路:就是按照竖直的线走到头,然后拐回去,直到最后连玩取余2看是谁走最后一步了。 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; int main () { ll n,m;cin>>n>>m; l

lvy_yu_ET的博客 561

使用 Python 爬虫抓取 IMDb 电影信息 - 评分、评论与基本信息抓取教程

本文介绍了如何使用 Python 爬虫技术抓取 IMDb 电影评分、评论和基本信息。我们分别展示了通过IMDb API和两种方法抓取数据,并进行了数据存储、分析与可视化。在未来,我们还可以基于这些数据开发电影推荐系统、情感分析工具等,进一步丰富电影数据的应用场景。通过这些实践,您不仅学会了如何抓取和存储数据,还可以通过这些基础来构建自己的数据分析应用,获取更丰富的电影数据。

2201_76125261的博客 601

2021牛客暑期多校训练营2,签到题CDFKI

2021牛客暑期多校训练营2 题号 标题 已通过代码 通过率 团队的状态 A Arithmetic Progression 点击查看 6/72 未通过 B Cannon 点击查看 34/104 未通过 C Draw Grids 点击查看 1537/2307 通过(结论-奇偶性) D Er Ba Game 点击查看 1588/3007 通过(模拟) E Gas Station 点击查看 1/20 未通过 F Girlfriend 点击查看 620/3053 通过(计算几何) G League of Le

小哈里的博客 930

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

2022牛客多校2 J-Link with Arithmetic Progression

示例1。

weixin_54562114的博客 405

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

2022牛客多校训练第二场 J题 Link with Arithmetic Progression

三分

m0_51171995的博客 382

2021牛客暑期多校训练营2

2021牛客暑期多校训练营2 题号 题目 知识点 A Arithmetic Progression B Cannon C Draw Grids D Er Ba Game E Gas Station F Girlfriend G League of Legends H Olefin I Penguins bfs J Product of GCDs K Stack L WeChat Walk ...

qq_35975367的博客 395

[三分][最小二乘法]Link with Arithmetic Progression 2022牛客多校第2场 J

给出一个长度为n的数组,现在对于每个数ai都可以将其变为另一个数bi,该次操作代价为二者差值的平方,求令数组a成为等差数列所需要的最小代价。另外这道题目还可以用最小二乘法来拟合直线,这个方法据说是官方正解,但感觉还是比较难想到的。这道题目和去年济南站D题很像,...

Cloth的博客 522

“蔚来杯“2022牛客暑期多校赛 第二场 J-Link with Arithmetic Progression

“蔚来杯“2022牛客暑期多校赛 第二场 J-Link with Arithmetic Progression

weixin_69232161的博客 321

“蔚来杯“2022牛客暑期多校训练营2 个人题解集合

显然要生成无限物品,需要存在一个环且沿该环生成一轮得到的物品数目比原来更多,即为环上满足所有的边有。显然可以二分答案来做。那么可以分上下两个过程,分别存下所有的端点(带标记),每个乘客分配的轮数可以通过。首先枚举插入的括号数量,原来的括号序列和左括号比右括号多的数量。,即左括号的数量大于右括号的数量,并且使用的原括号的数量。的括号序列(不保证合法性),求在此基础上生成的长度为。如果目前枚举到的括号为左括号,并且使用的原括号的数量。如果此时枚举到的是一个右括号,并且。、使用的原来的序列中的括号数量为。...

HeartFireY的博客 991

Atcoder ABC340 A - Arithmetic Progression

Atcoder ABC340 A - Arithmetic Progression题解

2302_76207485的博客 640

牛客多校-Link with Arithmetic Progression-(三分总结)

就是给你一个数组,然后你每次可以让一个数a变为另一个数b,花费为(a-b)×(a-b)。然后问你让这个数组变成等差序列的最小花费。就是给你一个数组,每次你可以让一个数加1或者减1,然后把这个数组变成等差序列的最小花费。......

m0_52398496的博客 379

Almost Arithmetic Progression

A. Almost Arithmetic Progression time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Polycarp likes arithmetic progressions. A sequence [a1,a2,…,an...

代码演奏家 657

Arithmetic Progression

“In mathematics, an arithmeticprogression (AP) or arithmetic sequence is a sequence of numbers such that thedifference between the consecutive terms is constant. For instance, thesequence 5, 7, 9, 11,

Pis_arc的专栏 688

Arithmetic Progression解题报告

题目摘要:“In mathematics, an arithmeticprogression (AP) or arithmetic sequence is a sequence of numbers such that thedifference between the consecutive terms is constant. For instance, thesequence 5, 7, 9

卫少的专栏 1400

D. Almost Arithmetic Progression

D. Almost Arithmetic Progressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp likes arithmetic progressions. A sequence [a1,a2,…,an][a1,...

Swust_ZzK的博客 1375
上一篇: POJ2796 Feel Good——单调栈
下一篇: 2021牛客多校第二场 B——Cannon
Linda_yezi_coder
博客等级 码龄7年 20粉丝 88原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值