Mishka and Interesting sum CodeForces - 703D(离线处理)

Open Interpreter利用Code Interpreter实现本地化 作为一个可以在本地环境中运行的工具,Open Interpreter可以访问互联网,没有文件大小和运行时间的限制,并且可以利用任何包或库。去年7月,OpenAI发布了一个强大的插件,名为Code Interpreter(代码解释器),它可以根据用户的自然语言需求生成并执行代码解决方案,帮助完成各种任务,如数据分析、图表创建和文件编辑等。Open Interpreter不仅是一个编码解释器,它还是一个强大的工具,专注于处理复杂任务,将GPT-4代码解释器的强大功能与本地开发环境的灵活性完美结合在一起。 阅读详情

Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, …, an of n elements!

Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can’t process large arrays. Right because of that she invited you to visit her and asked you to process m queries.

Each query is processed in the following way:

Two integers l and r (1 ≤ l ≤ r ≤ n) are specified — bounds of query segment.
Integers, presented in array segment [l,  r] (in sequence of integers al, al + 1, …, ar) even number of times, are written down.
XOR-sum of written down integers is calculated, and this value is the answer for a query. Formally, if integers written down in point 2 are x1, x2, …, xk, then Mishka wants to know the value , where — operator of exclusive bitwise OR.
Since only the little bears know the definition of array beauty, all you are to do is to answer each of queries presented.

Input
The first line of the input contains single integer n (1 ≤ n ≤ 1 000 000) — the number of elements in the array.

The second line of the input contains n integers a1, a2, …, an (1 ≤ ai ≤ 109) — array elements.

The third line of the input contains single integer m (1 ≤ m ≤ 1 000 000) — the number of queries.

Each of the next m lines describes corresponding query by a pair of integers l and r (1 ≤ l ≤ r ≤ n) — the bounds of query segment.

Output
Print m non-negative integers — the answers for the queries in the order they appear in the input.

Example
Input
3
3 7 8
1
1 3
Output
0
Input
7
1 2 1 3 3 2 3
5
4 7
4 5
1 3
1 7
1 5
Output
0
3
1
3
2
Note
In the second sample:

There is no integers in the segment of the first query, presented even number of times in the segment — the answer is 0.

In the second query there is only integer 3 is presented even number of times — the answer is 3.

In the third query only integer 1 is written down — the answer is 1.

In the fourth query all array elements are considered. Only 1 and 2 are presented there even number of times. The answer is .

In the fifth query 1 and 3 are written down. The answer is .

一个比较厉害的思维,边做便学。
最后这个题就是转化为如何求一个区间内有多少个不同的数的异或值(关键是这个)。看代码;

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include <time.h>
#include<fstream>
#define maxn 1000003
using namespace std;
struct seg
{
    int l,r,index;
    bool operator <(const seg& rhs)const{return r<rhs.r;}
};//n个询问的结构,
seg p[maxn];
int a[maxn],c[maxn],sum[maxn],pre[maxn],res[maxn];
int n;
int lowbit(int x)//下面三个函数是异或版的树状数组,当然线段树也是可以的
{
    return x&(-x);
}
void add(int x,int v)
{
    for(int i=x;i<=n;i+=lowbit(i))
        c[i]^=v;
}
int getSum(int x)
{
    int ans=0;
    for(int i=x;i>=1;i-=lowbit(i))
        ans^=c[i];
    return ans;
}
int main()
{

     map<int,int>mp;//这个用来映射一个数最新出现的坐标
     memset(c,0,sizeof(c));
     scanf("%d",&n);
     sum[0]=0;
     for(int i=1;i<=n;i++)//数组的输入
     {
         scanf("%d",&a[i]);
         sum[i]=sum[i-1]^a[i];//同时求各个点的前缀异或值,和前缀和的写法是一样的
         pre[i]=mp[a[i]];//这个是一个链状结构,在这个结构中,所对应的a数组的值都是一样的,也就是说map的作用就是这个
         mp[a[i]]=i;//更新最新位置
     }
     int m;
     scanf("%d",&m);
     for(int i=1;i<=m;i++)
     {
         scanf("%d%d",&p[i].l,&p[i].r);
         p[i].index=i;
     }//输入m个询问
     sort(p+1,p+1+m);//以r为标准从小到大排序
     int j=1;
     for(int i=1;i<=m;i++)
     {
        for(;j<=p[i].r;j++)//以每次查询的r为界限,把所有的值尽可能的往右更新,因为查询已经排过序了,所以不会出现我在某个区间上的一个值已经更新更大的坐标的这种情况
        {
            if(pre[j])add(pre[j],a[j]);//如果前面有节点,就把这个点置为0,就是只要在异或一次
            add(j,a[j]);//因为初始化每个点的值都是0,所有只要异或一次,
        }
        res[p[i].index]=sum[p[i].r]^sum[p[i].l-1]^getSum(p[i].r)^getSum(p[i].l-1);,求出这个区间上的不同的异或值
     }
     for(int i=1;i<=m;i++)
        printf("%d\n",res[i]);//把存好的答案输出即可
    return 0;
}
ESP32设备驱动-VCNL4040趋近传感器 VCNL4040 将趋近传感器 (PS)、环境光传感器 (ALS) 和高功率 IRED 集成到一个小型封装中。它通过CMOS工艺将光电二极管、放大器和模数转换电路集成到一个芯片中。 阅读详情

相关推荐

[Vue][面试]谈谈你对MVC、MVP和MVVM的理解

谈谈你对MVC、MVP和MVVM的理解 答题思路:此题涉及知识点很多,很难说清楚,说透彻,因为MVC,MVP这些我们前端程序员自己甚至都没用过。但是恰恰反映了前端这些年从无到有, 从有到优的变迁过程,因此沿此思路回答将十分清除。 Web1.0时代 在web1.0时代,并没有前端的概念。开发一个web应用多数采用ASP.NET/Java/PHP编写,项目通常由多个aspx/jsp/php文件构成,每个文件中同时包含了HTML、CSS、JavaScript、C#/Java/PHP代码, 系统整体架构可能如下图所

你好,欢迎光临! 729

Codeforces Round #498 (Div. 3)-A. Adjacent Replacements

A. Adjacent Replacements time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka got an integer array aa of length nn as a birthday...

短发 341

ASP.NET Core Identity + Mysql(实战一)——注册登陆

在进行实战之前,我们先来了解一下Identity。 ASP.NET Core Identity是用于构建ASP.NET Core Web应用程序的成员资格系统,包括成员资格、登录和用户数据存储。简单的来讲包括: 1.用户数据存储(使用任意你喜欢的关系型数据库,从sqllite到mysql、sqlserver等等,由Entity Framwork 支持) 2.登陆、注册外加身份认证(基于coo...

weixin_40359716的博客 1402

LWC 70: 777. Swap Adjacent in LR String

LWC 70: 777. Swap Adjacent in LR String 传送门:777. Swap Adjacent in LR String Problem: In a string composed of ‘L’, ‘R’, and ‘X’ characters, like “RXXLRXRXL”, a move consists of either replacing o

Demon-初来驾到 997

Allegro 16.6 高级技巧实战:用Region规则和动态间距搞定高密度连接器布局布线

本文深入探讨了Allegro 16.6在高密度连接器布局布线中的高级技巧,重点介绍了Region规则和动态间距属性的应用。通过局部规则覆盖和分层控制,解决0.5mm以下引脚间距的布线难题,提升PCB设计效率和质量。

weixin_30352645的博客 444

告别糊涂账!用CKM3底表逻辑自建物料成本监控报表(含ABAP代码片段)

本文详细介绍了如何利用CKM3底表逻辑自建物料成本监控报表,解决标准报表无法穿透成本差异根源的问题。通过ABAP代码片段和四步架构法,帮助财务团队精准分析成本构成,优化成本核算批量处理,实现多维透视差异分析,提升成本监控效率。

weixin_30740295的博客 269

Educational Codeforces Round 53: E. Segment Sum(数位DP)

  题意: 给你三个数字L, R, K,问在[L, R]范围内有多少个数字满足它每一位不同数字不超过k个,求出它们的和   思路: 明显的数位DP了,套路都一样,不过这道题是记权值而不是满足条件的数字个数,所以还需要再开一个计贡献数组 dp[len][x][sum]表示当前有len位数字还不确定,在此之前0~9每个数字出现的状态为x,已经有sum个不同数字的方案个数   #i...

加载中... 901

通义千问对接FreeSWITCH实现大模型呼叫中心

通义千问是由阿里云开发的大规模语言模型,具备优秀的自然语言处理能力,支持文本生成、问答对话、摘要提取等多种任务。它不仅拥有丰富的知识储备,还能根据上下文灵活调整回答策略,适用于各种复杂场景下的自动化交流。FreeSWITCH是一个开源的多媒体通信服务器,提供了包括VoIP通话、即时消息传递在内的多种通信服务。它的模块化设计允许开发者根据实际需求定制功能,广泛应用于企业级通信系统中。通过集成通义千问,FreeSWITCH能够实现更智能的客户服务体验。

技术永不眠 Q:53195017 1505

1006A Adjacent Replacements

A. Adjacent Replacements time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka got an integer array aa of length nn as a birthday...

memory_qianxiao的博客 500

Windows Server 安装 AD 域服务一直失败?一招搞定“请求添加或删除指定服务器上的功能失败”

这个问题看似简单,其实暗藏了几个“隐藏门槛”,像是服务未开启、端口未开放、网卡组件未勾选、虚拟机 SID 冲突等等,尤其在云上装 AD 更容易踩坑。建议每一步都排查一下,尤其是服务和防火墙,很多安装失败其实都是被这两处给卡住了。如果你也遇到 “请求添加或删除指定服务器上的功能失败”,不妨参考这篇文章挨个试试看,说不定就能解决问题!

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1440

5.30华为OD机试真题 新系统 - 魔法阵的能量收集 (Java/Py/C/C++/Js/Go)

5.30华为OD机试真题 新系统 - 魔法阵的能量收集 (Java/Py/C/C++/Js/Go)

算法大师! 762

Adjacent Replacements(CF-1006A)

Problem Description Mishka got an integer array a of length nas a birthday present (what a surprise!). Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm...

Alex_McAvoy的博客 413

【GlobalMapper精品教程】038:模拟水位上升(洪水淹没分析)案例教程

基于数字高程模型 ( DEM )格网模型,实现给定水深情况下洪水淹没区的计算模型,讨论洪水淹没演进过程可视化实现的关键技术,以三维可视化方式,动态而形象地模拟在指定洪水水位下的洪水淹没演进过程。

智慧空间实验室 2893

codeforces703D、Mishka and Interesting sum(区间偶数异或+离线处理)

                                                                                                      D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megaby...

Amove 339

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

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

codeforces 703D D. Mishka and Interesting sum(树状数组)

D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Little Mishka enjoys programming. Since her birth...

c_czl的博客 256

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

CodeForces 703D Mishka and Interesting sum

D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Little Mishka enjoys progra

modricwang的博客 1029

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 树状数组

&#13; D. Mishka and Interesting sum&#13; 链接:&#13; http://codeforces.com/problemset/problem/703/D&#13; 题意:&#13; 给一个序列 每次询问一个区间 求区间中出现次数为偶数次的数的异或和&#13; 代码:&#13; &#13; 1 #include&lt;iostream&...

花海 172

[树状数组]Mishka and Interesting sum(codeforces703D)

Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Little Mishka enjoys programming....

dingfei496705的博客 122

Codeforces703 D.Mishka and Interesting sum(离线+树状数组)

题意: 给定长度为n的序列a,m次操作, 每次操作给出L,R,要求计算区间[L,R]中出现偶数次的数的异或和。 数据范围:n,m<=1e6,1<=a(i)<=1e9

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 210

Codeforces 703D Mishka and Interesting sum 树状数组

题目:http://codeforces.com/contest/703/problem/D 题意: 给你n个数,m个区间询问 求区间出现次数为偶数次的数的异或和 分析: 如果是奇数次呢?我们知道a^a=0 所以直接前缀异或和就可以处理。所以思考有没有一种反异或运算呢?自己模拟一遍发现这样是错误的。换一个思路考虑,将奇数次变为偶数次来处理,只需...

244

Codeforces-703D Mishka and Interesting sum

题目大意: 给你m个区间[l, r],让你计算区间[l, r]中出现偶数次的数的异或和 解题思路: 异或的性质比较明显 a ^ a = 0 也就是说如果让你计算奇数次的异或和这就是裸题直接搞就行。 但是是偶数的话,我们的想法其实很简单,对于[l, r]区间内出现的数,都再多异或一次 比如1 2 1 3 3对于这个序列,计算偶数次可以1 ^ 2 ^ 1 ^ 3 ^ 3 ^ 1 ^ 2 ^

Wilbert的博客 717

Mishka and Interesting sum CodeForces - 703D (离线 树状数组 区间内不同数字异或和)

题目链接 题意:给你n个数,q次询问,每次询问求区间上出现偶数次的数 的异或和。 思路:区间的异或实际上就是区间内出现奇数次的数的异或和(偶数次的异或后为0),但是现在要求的是出现偶数次的异或和,我们可以再异或一下区间内的所有不相同数,这样每种数出现次数都加了1,奇偶就交换了,求得的答案也就成了区间上出现偶数次的异或和,现在关键是怎么求区间内不相同的数的异或和,可以树状数组离线操作,每次只把出...

skyline的分享专栏 288

Codeforces703D-Mishka and Interesting sum-离线树状数组

(有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 题意:传送门  原题目描述在最下面。  询问一个区间内出现次数为偶数次的数字的异或和。 思路:  先求出区间异或前缀和,其实就是出现次数为奇数次的数字的异或前缀和和。  然后用离线树状数组树状维护区间内区间内每种数字的前缀和。  最后的答案就是上面两个前缀和 差分一下 的异或和。 AC代码: #include<...

ako2654的博客 109

CodeForces 703D Mishka and Interesting sum (树状数组处理异或和)

题意:求区间上出现偶数次的数 的异或和。 分析: 如果求出现奇数次的数 的异或和,则只需预处理前缀异或和,然后马上就能求出来了。一个数异或偶数次为0。             所以这题把问题简单化,把偶数次变奇数次,奇数次变偶数次。(主要思想)            1. 预处理前缀异或和(偶数次被异或没了)            2.pre数组记录当前数上一

Follow My Heart 742

【29.82%】【codeforces 703D】Mishka and Interesting sum

【题解】 题意: 给n个数字组成有序数列; 给m个询问. 对于每个询问区间。输出这个区间里面出现次数为偶数次的所有数的异或值; 做法: 我们可以先求出这段区间里面所有(包括重复的数字)数字的异或值p1; (出现次数为偶数的数x,这偶数个x的异或值为0(x^x==0),出现次数为奇数的数y(y^y^y==y),这奇数个数y的异或值为y,考虑到...

AWCXV 127

codeforces703D 【Mishka and Interesting sum】

首先,题意就不多说了; 观察题目,我们发先要求的是出现偶数个数的数的亦或和,根据亦或的性质我们知道,一个数如果被亦或偶数次,那么就是它本身, 说以稍加思索~~(很容易)~~可以发现, 区间出现偶数次的数的异或和=区间异或和^区间所有不同数的异或和。所以我们只需用线段树维护区间内所有不同数的亦或和,而区间亦或和,具体可参见sp3267,只需在前者上做一些改动,,而区间亦或和,这可以用前缀和来完成。 ...

mzj_best的博客 381
上一篇: TIANKENG’s restaurant HDU - 4883
下一篇: Just a Hook HDU - 1698(线段树的懒惰标记)
coldfresh
博客等级 码龄10年 107粉丝 405原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值