codeforces 1030E Vasya and Good Sequences

uniapp - 详细解决 H5 网页报错 Uncaught Error: Async component timed out after ? ms.(移动端h5页面白屏或加载缓慢失败,超时报错处理) uni-app,vue3,网页,h5,移动端,手机H5页面,浏览器,报错,uniapp报错,Asynccomponenttimedoutafter,如何解决这个问题,vue3Asynccomponenttimedoutafter,异步组件超时了怎么办,async,详细解决方案,AsyncComponents异步组件,导致页面打不开了,白屏什么也不显示,网页载入非常慢卡顿,vue3网站报错,超时,nuxt3,详细解决方案,浏览器控制台报错,爆红并且页面卡住了,依旧报错,找不到异步组件的报错 阅读详情

题解

很容易观察到的两点是,aia_iai​有用的只有二进制表示下的1的个数,那么既然只有个数有用,如果某个区间的1的个数的和是偶数的话,会有很大可能是好序列,在验证过程中可以发现,1 1 4这种序列是不可以的,因为4*2>6,简单的说,序列总和必须要至少为其中最大的数的两倍,那么就转化为新的问题:

求一个序列中有多少连续子序列的和是偶数,并且和不小于最大值的两倍

(我的做法可能有点复杂,细节很多)
第二个限制非常难搞,但是我们注意到,新的序列bib_ibi​中,最大值大约是60多。可不可以枚举最大值?可不可以把区间按最大值分类?假设枚举出一个最大值M,序列(指新序列,下同)中某些位置是等于M的,我们要考虑的是跨越了至少一个这些位置,并且没有包含比M大的数的区间。假设b[cur]=M,枚举i>=cur作为区间右端点,(因为最多枚举60次最大值,所以这部分枚举的复杂度是O(60n),是可以接受的)我们要快速找有多少个合法左端点。
考虑怎么搞掉限制2就好了,如果右端点是jjj左端点是iii,那么是要求Sumb(j)−Sumb(i−1)>=M∗2Sum_b(j)-Sum_b(i-1)>=M*2Sumb​(j)−Sumb​(i−1)>=M∗2( * )。我们注意到题中的ai>=1a_i>=1ai​>=1也就是说bi>=1b_i>=1bi​>=1加上M最大为60,这意味着,我最多从j暴力往前找60*2=120个位置,( * )式必然能够被满足,然后就只需要考虑在此位置之前Sumb(i)Sum_b(i)Sumb​(i)有多少个和Sumb(j)Sum_b(j)Sumb​(j)奇偶性一样的就可以了。

这是大体框架,其次还需要注意不能包含比M大的数值,需要在细节上加一些处理。

代码

//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
typedef long long ll;
inline ll read()
{
	char ch=getchar();ll ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}
using namespace std;

const int INF=1<<30;

const int maxn=300000+10;

int a[maxn],sum[maxn],ji[maxn],ou[maxn],t[maxn];

inline int cal(ll x)
{
	int ret=0;
	for(;x;x>>=1) ret+=x&1ll;
	return ret;	
}

inline int check(int x){return !(x&1);}
inline int s_ji(int l,int r){return ji[r]-(l==0?0:ji[l-1]);}
inline int s_ou(int l,int r){return ou[r]-(l==0?0:ou[l-1]);}

int main()
{
	int n;cin>>n;
	
	ou[0]=1;
	rep(i,1,n) {
		a[i]=cal(read()),sum[i]=sum[i-1]+a[i];
		ji[i]=(sum[i]&1)+ji[i-1];
		ou[i]=!(sum[i]&1)+ou[i-1];t[i]=a[i];
	}
	
	sort(t+1,t+n+1);
	long long ans=0;
	int k=unique(t+1,t+n+1)-t-1;
	rep(o,1,k)
	{
		int M=t[o],cur=1,pre=0;
		while(a[cur]!=M) {
			if(a[cur]>M) pre=cur;
			++cur;
		}
		while(cur<=n)
		{
			while(cur<=n&&a[cur]!=M) {
				if(a[cur]>M) pre=cur;
				++cur;
			}
			
			int j;
			for(j=cur;(a[j]<M ||j==cur)&& j<=n;++j)
			{
				int pos=cur-1;
				while(pos>=pre && sum[j]-sum[pos]<M*2) --pos;
				if(pos<pre) continue;
				
				if(sum[j]&1) ans+=s_ji(pre,pos);
				else ans+=s_ou(pre,pos);
			}
			cur=j;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

DDR5 的 PI: DIMM 上 PMIC,正在制造一批“新型 EMI 问题” DDR5 的 PI,不再只是“供电设计”,而是一次“噪声管理设计”。电压稳定本地调节高频噪声EMI 风险系统不确定性DDR5 真正难的地方,不是跑起来,而是——在最差条件下,它还能不能一直跑。而 DIMM 上那颗 PMIC,正是你绕不开的关键角色。 阅读详情

相关推荐

Silvaco Atlas入门指南——从零开始掌握半导体器件仿真

本文为Silvaco Atlas半导体器件仿真软件的入门指南,详细介绍了从零开始掌握该工具的核心流程。内容涵盖Atlas的基本概念、仿真流程、核心文件(输入、结构、输出文件)、交互式与批处理两种操作模式,并逐步演示了如何从定义网格、划分区域、设置电极到进行掺杂、选择物理模型并求解,最终获取和分析器件特性的完整步骤。旨在帮助微电子相关专业人员和工程师快速上手这一强大的“数字实验室”,提升半导体器件设计与研发效率。

weixin_29306317的博客 410

codeforces 1030E (暴力+思维)

题目网址:http://codeforces.com/problemset/problem/1030/E 题意: 给定一些数,可将区间 l ~r 中某些数的二进制位的1的位置更换, 使得最终区间所有数异或和为0,求这样的区间个数。 思路: 在那里瞎dp了好久,wa的很彻底,借鉴了一下别人的思路。 区间合法的条件是: 这个区间1的个数为偶数,并且区间中二进制位1最多的一个数的二进制个数小...

DS00HY的小博客 313

QCC308x/3095收发一体:TX/RX双模一拖二与多编码广播实战解析

本文深度解析高通QCC308x/3095蓝牙音频芯片的TX/RX双模功能与广播应用。芯片支持发射和接收模式下的“一拖二”连接,并能实现LE Audio多设备广播,显著提升多设备音频切换体验与商业广播能力,适用于健身、导览等丰富场景。

g9h0i1的博客 1009

CF1030E Vasya and Good Sequences

Vasya有n个64位二进制正整数,小R有一种魔法,它可以让一个二进制数的任意两位交换,比如它可以将7(...000111)变成11(...001011)或者22(...010110),等等。对于一个序列,如果Vasya可以通过对任意多个序列中的数(可以是0个)使用任意多次(可以是0次)这种魔法,使得序列中的所有数异或和得0,则称这是一个好的序列。给定n个数a_1,a_2,a_3...a_n,问有...

weixin_33810006的博客 192

OLED 驱动模块程序代码

作为嵌入式软件开发,可能经常会使用单片机连接驱动显示屏,实现人机交互的功能,通常可选择的有 OLED 和 LCD 等,其中相关驱动代码例程网上更是数不胜数。 本文介绍的是 OLED, 常见代表有 0.96 寸的OLED,网上也有很多相关的驱动代码,但是大部分代码都是能用即可,不是特别关注驱动代码的整体架构,以下是个人整理的 OLED 驱动代码,支持配置 SPI 和 IIC 两种接口方式(目前只是测试了 SPI,IIC 有待验证)。

大橙子的博客 4295

codeforces 1030E

根据题意,反正就是随便安排每个数字1的位置了,那么一段区间是good,首先要是1的个数是偶数,因为1个1消掉另一个1,然后就是要一个数的1要用另外一个1去消掉,所以最多的1不能比所有1的一半大,那么这个区间是good的。 又考虑到b[i](每个数字1的个数)是1到63的,所以以每个i为左端点,只要for循环遍历j&lt;=i+63,sum[j]-sum[i-1]%==0,2*mx&lt;=sum...

binarycopycode 432

Unreal5从入门到精通之初学者碰到解决不了的问题怎么办?

在学习Unreal的过程中,你曾陷入困境了吗?对于我来说,这种情况发生得比我愿意承认的要多得多。幸运的是,除了一般地在网上搜索之外,还有很多地方可以获得虚幻引擎的帮助。

TxNet 989

E. Vasya and Good Sequences(异或)

当a2=7→11,a3=14→11且11 ⊕ 11 = 0时,对(2,3)进行配对是有效的,其中⊕表示按位异或运算。当a1=6→3,a2=7→13,a3=14→14且3 ⊕ 13 ⊕ 14 = 0时,对(1,3)进行配对是有效的。,an,Vasya想计算整数对(l,r),使得1≤l≤r≤n且序列al,al + 1,…输出 打印一个整数 - 对于1≤l≤r≤n且序列al,al + 1,…,ar很好,返回配对(l,r)的数量。在第二个示例中,配对(1,2),(2,3),(3,4)和(1,4)都是有效的。

m0_64158084的博客 548

20、七鳃鳗繁殖与早期生活史:从水质到养殖的全面解析

本文全面解析了七鳃鳗的繁殖与早期生活史,重点探讨了水质对幼体生存的影响、养殖密度与生长关系、变态过程的时间与大小特征,以及人工繁殖在濒危物种恢复和入侵物种控制中的应用。同时,文章分析了大规模养殖面临的挖掘基质需求、空间限制、清洁管理、疾病防控及微生物环境等挑战,并强调实验室养殖对科学研究和种群管理的重要意义。随着技术进步,未来有望扩展更多物种的繁殖研究,揭示七鳃鳗生物学的进化奥秘,实现资源的可持续利用。

l6m7n8的博客 121

一文讲透 SAP VDM 命名里的前缀与后缀:看懂 I_、C_、A_,把 CDS 视图栈搭得又稳又好用

SAP S/4HANA 的 CDS 视图命名规范解析 摘要:本文详细解析 SAP S/4HANA 中 CDS 视图的 VDM 命名规范。通过前缀(如 I_、C_、R_)区分视图层级,后缀标记附加角色,结合 @VDM.viewType 注解形成完整语义体系。I_作为稳定接口层,C_面向特定场景裁剪,R_限定应用域内复用,A_提供远程 API 接口。命名规范使团队能快速识别视图用途、依赖关系和扩展边界,确保模型长期可维护性。文章结合制造业物料主数据、Fiori 应用等实际案例,说明如何通过规范命名构建清晰的视图

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 227

E. Vasya and Good Sequences

题目 题意:     给出一组序列,对于其中的元素可以任意改变其二进制下1的位置。求出区间[l,r],使得这个区间的元素在操作后异或值为0。输出这样的区间数量。     1≤n≤3⋅105,1≤ai≤10181≤n≤3⋅10^5,1≤a_i≤10^{18}1≤n≤3⋅105,1≤ai​≤1018 分析:     首先对于这种问题,一般都是枚举左区间,然后去计数右区间。     由于二进制位的数可以...

weixin_44316314的博客 304

第一节:Vben Admin介绍和初次运行

本文是【实战Vben Admin + Python】的第一节,本文内容主要是介绍Vben Admin框架和我们后端使用的技术,开发环境和工具的准备本节文章的目的是Vben Admin的简单介绍,通过配置可以让项目前端运行起来,由于项目默认开启了mock,展示的都是静态模拟数据,我们在此基础上,下一节将研究分析下Vben Admin的目录。为我们后端搭建准备。

cuiwin的专栏 7439

Codeforces Contest 1030 problem E Vasya and Good Sequences——DP

Vasya has a sequence a consisting of n integers a1,a2,…,an. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For e...

天翼之城的博客 297

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

CodeForces 1030E Vasya and Good Sequences 位运算 思维

考虑用值域来优化算法

_int_me的博客 287

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

code forces 1030E Vasya and Good Sequences

链接: http://codeforces.com/problemset/problem/1030/E 思路: 如果区间[ L, R ] 想要满足good ,那么充分必要条件就是 1  [ L, R ] 的每一位1 的个数和是偶数,  2 [ L, R ]中的二进制1 最多的一个数的1 的个数的2倍不能超过sum 。  那么一个 longlong 的数,二进制1 最多 64 (1e18   62...

yjt9299的博客 327

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

Codeforces1058 E. Vasya and Good Sequences(思维,抽屉原理暴力)

题意: 解法: 令b[i]=a[i]二进制中1的个数, 以下的所有讨论都是在b[]的基础上的. 满足条件得区间一定满足: 1.区间内1的总数是偶数. 2.区间内1的最大值*2<=区间内1的总数. 条件2比较容易遗漏, 因为当最大值>区间1总数/2时,根据抽屉原理: 不管怎么分配1的位置,最大值一个位置都至少有一个位置没有被消掉. 考虑枚举r,计算有多少个l满足条件,使得[l,r]是合法区间. 发现b[i]总是>=1的,因此当区间长度r-l+1>=61时,条件2一定成立, 此

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 214

Codeforces Round #512(Technocup 2019 Elimination Round 1) E. Vasya and Good Seque (Codeforces 1030E)

题目:Vasya and Good Sequences 思路: 由于位置可以变化,所以不需要关心具体的数是多少,只需要知道二进制表示中的1的个数是多少就可以了。 然后对于一段数,把1的个数加起来,如果是偶数,就说明异或后可以为0,否则就不能。 最后还要满足最长的数的两倍小于整个的总和。 代码: #include&lt;bits/stdc++.h&gt; using namespace std; ...

iwi 350

2018.09.23 codeforces 1053B. Vasya and Good Sequences(前缀和)

传送门 考试的时候卡了一会儿。 显然这个答案只跟二进制位为1的数量有关。 还有一个显然的结论。 对于一个区间[l,r][l,r][l,r],如果其中单个数二进制位为1的数量最大值不到区间所有数二进制位为1的数量之和的一半即maxn∗2≤summaxn*2\le summaxn∗2≤sum,并且sum是偶数那么这个区间是好的。 继续考虑,如果我们枚举左端点l和右端点r,那么当sum[r0]−sum[...

苟为蒟蒻又何妨 558

Codeforces Round #512 E - Vasya and Good Sequences 思路+dp+暴力详解

题意: 给定一段长度最大为 3e5的序列,每个数的二进制位的1和0可以互换,即二进制1的个数相同的数可以互换, 问有多少个连续的子序列(子区间),在可以使用上述互换的条件下,能够达到区间异或和为0 思路: 有前面的互换我们可以知道,对于给定的每个a[i] 我们只需要考虑其二进制位有几个1就OK了; 可是我想的是这个连续自序列必须满足“可以划分成相等的两部分”,后来想到(正解): 只要和...

床前明月光 398

[CF1030E]Vasya and Good Sequences

[CF1030E]Vasya and Good Sequences 题目大意: 给定一个长度为\(n(n\le3\times10^5)\)的数列\(a_i(1\le a_i\le10^{18})\)。可以任意对若干数进行操作,交换这个数的任意二进制位。求有多少区间,使得这个区间内的数经过操作使得异或和为\(0\)。 思路: 显然这与\(a_i\)本身的值无关,只与二进制下\(1\)的个数有关。 一...

weixin_34391445的博客 220

Codeforces Round #512 (Div. 2 E. Vasya and Good Sequences 异或问题

题目连接 题意: 给你n个数,每个数的二进制可以拆开,这个数拆开之后可以任意换0和1的位置,问有多少个l r区间 能满足异或和为0   做法:主要是看1的个数问题,由于0 1可以互换位置,那么我可以把1换成同一个位置就行,但是如果是奇数个,那么1就消不全 ,偶数个就可以消完。 那么我维护一个从尾到头的后缀和,分别记录每个数1的个数的后缀和,以及奇数后缀和,偶数后缀和。 枚举左区间时...

twh233的算法blog 288

[Codeforces1058E][分治]Vasya and Good Sequences

翻译 给你一些数 你可以把这些数二进制表示中的1任意移动 问有多少个区间满足 你做完上面的操作后他们的异或和为0 题解 显然是给你一些数 你要把每个数分成两半 加入两个集合 要求这两个集合的数值相同 大概就是结论吧… 你会发现 这一段区间满足条件的话 当且仅当区间权值和&amp;gt;=区间MAX*2 然后分治就好了… #include&amp;lt;cstdio&amp;gt; #include&amp;lt;cstr...

Rose_max的博客 351

Codeforces Round #512 (Div. 1) B. Vasya and Good Sequences

题目:http://codeforces.com/contest/1058/problem/E 粘不过来题目,自己点开看吧QAQ 题目大意:给你一列数,现在有一种操作,就是对一个数,可以任意交换其二进制的两位,操作次数不限。问你有多少个字串 [ l , r ],可以经过上述操作,使该字串的异或和为0。   题解: 一段数的异或和为0,即让这一串数二进制下每一位的1的个数都为0。于是题目可...

Niconicoqaq的博客 634

Codeforces 1030E 【暴力构造】

LINK 题目大意:给你n个数,你可以交换一个数的任意二进制位,问你可以选出多少区间经过操作后异或和是0 思路 充分必要条件: 区间中二进制1的个数是偶数 区间中二进制位最多的一个数的二进制个数小于等于和的一半 然后因为每个数最少会贡献1,所以直接暴力向前跳128位,再之前的就直接前缀和做掉就可以了 #include<bits/stdc++.h> using namespace...

weixin_30646505的博客 151

51Nod 1555 布丁怪 分治

Description 一个n * n的矩阵有n个节点,它们纵坐标和横坐标互不相同,问有多少个k*k的矩阵存在有k个元素且每行每列互不相同。 Sample Input 5 1 1 4 3 3 2 2 4 5 5 Sample Output 10 问题可以变为问一个序列中有多少个子序列里面的数编号连续。 考虑分治,维护最大值最小值,分情况讨论。 1.最大值和最小值都在右边 这时只可能会出现一种...

xgc_woker的博客 262
上一篇: Codeforces Round #507 (Div. 2) D~E
下一篇: codeforces 1070A
QWsin
博客等级 码龄11年 51粉丝 209原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值