双剑合并 XOR Trie.

运放+光耦补偿设计实战:手把手教你LLC环路零极点手动配置(附仿真文件) 本文详细介绍了运放与光耦在LLC环路补偿设计中的实战应用,重点讲解零极点手动配置方法及仿真验证。通过三型补偿网络设计,帮助工程师解决LLC谐振变换器的环路稳定性问题,提升开关电源的动态响应和精度。 阅读详情

【题意】给你两行数,一行n个,一行m个,现在要你分别在这n个和m个里面找出1个,使得它们的异或和最大!

【分析】典型的XOR Trie.枚举一行数,另一行用XOR Trie存起来,然后这样就可以很快查询了。

【AC代码】

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e7+2;
struct node{
    int ch[N][2];
    int root,L;
    int newnode(){
        ch[L][0]=ch[L][1]=-1;
        return L++;
    }
    void Init(){
        L=0,root=newnode();
    }
    void Insert(int x){
        int now=root;
        for(int j=30; j>=0; j--){
            int go=(x&(1<<j))?1:0;
            if(ch[now][go]==-1){
                ch[now][go]=newnode();
                now=ch[now][go];
            }else
                now=ch[now][go];
        }
    }
    int Query(int x){
        int now=root;
        int ans=0;
        for(int j=30;j>=0;j--){
            int go=(x&(1<<j))?1:0;
            if(ch[now][!go]!=-1) ans|=(1<<j),now=ch[now][!go];
            else now=ch[now][go];
        }
        return ans;
    }
}Trie;
int main(){
    int T,n,m;
    scanf("%d",&T);
    while(T--){
        Trie.Init();
        int maxans=-1;
        int val;
        scanf("%d%d",&n,&m);
        for(int i=1; i<=n; i++){
            scanf("%d",&val);
            Trie.Insert(val);
        }
        for(int i=1; i<=m; i++){
            scanf("%d",&val);
            maxans=max(maxans,Trie.Query(val));
        }
        printf("%d\n",maxans);
    }
    return 0;
}


实证研究之|stata清洗charls数据 stata 阅读详情

相关推荐

STM32 CubeMX LwIP + freertOS 移植

生成代码,烧录即可ping通。这里要注意的是,要修改freertOS的任务栈大小,默认128,修改为1024,不修改就跑不起来。生产代码,下载进开发板。开发板网口与电脑网口通过网线直连,设置电脑本地网卡在同一网段。在以上无系统的cubeMX配置下继续添加freertOS。无系统LWIP协议栈设置,静态IP地址,关闭DHCP。先用裸机测试LAN8742A的网卡驱动。MCU型号:STM32F746NGH。下面进行freertOS系统移植。网卡型号:LAN8742A。系统时钟和时基定时器如下。

u011625775的博客 1378

【Spoj COT3】SG函数 Trie启发式合并

给一颗有黑白点的有根树,每次可以选一个白点并将其到根的路径染黑,问先手是否必胜以及第1步的可能选择。 子树间相互独立,用Trie维护一个子树操作一次可达SG值,这个用Trie启发式合并可求,需要打标记。 #include #include #include #include #include #define Rep(i, x, y) for (int i = x; i <= y; i

Owen_hzt的专栏 1156

避开STM32H7的‘保护陷阱’:从Option Byte机制深度解析读写保护原理与预防

本文深度解析STM32H723VGT6的Option Byte保护机制,详细讲解RDP读保护和WRP写保护的工作原理及配置方法,并提供硬件设计防御策略和软件预防性编程技巧,帮助开发者避免误触发保护机制导致芯片锁定的问题。

weixin_33686714的博客 448

【bzoj1954】【The xor-longest Path】【trie树】

Description  给定一棵n个点的带权树,求树上最长的异或和路径 Input The input contains several test cases. The first line of each test case contains an integer n(1<=n<=100000), The following n-1 lines each contains thr

sunshinezff的专栏 859

11n、11ac、11ax和11be MCS表(全网最全)

1、无线协商速率介绍及计算 2、附11n、11ac、11ax 完整MCS速率表

weixin_41500064的博客 2万+

激光甲烷传感器DIY指南:从DFB激光器选型到Herriott池光路搭建

本文详细介绍了如何DIY激光甲烷传感器,从DFB激光器选型到Herriott池光路搭建的全过程。通过TDLAS技术实现ppm级甲烷检测,适用于家用燃气泄漏监测和农业沼气监测等场景。文章包含核心器件选型、光路搭建技巧、信号调理方案及系统集成优化,为创客提供实用指南。

f9g0h的博客 601

hdu 5715 XOR 游戏(trie)

dp[i][k] = max(min(dp[j][k-1], s[j] ^ s[i]),dp[i][k])。 二分答案val,则dp[j][k-1]肯定要满足大于等于val,并且s[j] ^ s[i] >= val才能够转移。 在trie树上找最大的 s[j] ^ s[i]。。 #include #include #include #include #include #includ

LJ__ 1015

曲线最小二乘拟合基础

介绍曲线拟合的最小二乘原理,介绍了常规最小二乘和正交最小二乘算法,最后介绍了MathNet矩阵运算库的基本操作。

yh523的博客 1305

最大异或对(trie)

题目 在给定的N个整数A1,A2……AN中选出两个进行xor(异或)运算,得到的结果最大是多少? 输入格式 第一行输入一个整数N。 第二行输入N个整数A1~AN。 输出格式 输出一个整数表示答案。 数据范围 1≤N≤105, 0≤Ai<231 输入样例: 3 1 2 3 输出样例: 3 题解 将每个数字aia_iai​的二进制数插入到trietrietrie中 比较式将每个数aj(1≤...

MILLOPE的博客 586

STM32电机PID速度控制

2.3 STM32电机PID速度控制 之前的文章,完成了直流减速电机的PWM控制、电机测速。本篇文章,将实现电机的速度闭环控制。 在公众号:小白学移动机器人,发送:速度PID,即可获得本篇文章的STM32工程文件以及相关资料。 2.3.1 解决的问题 解决带编码器直流电机的速度闭环问题。 2.3.2 PID理论 将偏差的比例、积分、微分,通过线性组合构成控制量,用控制量对被控对象进行控制,这样的控制器称为PID控制器。在连续空间中,我们通常探讨模拟PID的控制原理,如图所示: 我们这里用电机速度控制为例,

「小白学移动机器人」一个专注分享移动机器人相关知识的公众号! 6万+

数学工具箱:Clarke与Park变换

本文详细解析了FOC(磁场定向控制)中的核心数学工具——Clarke变换与Park变换。首先阐述了坐标变换的必要性:将复杂的三相交流系统简化为直流系统,便于精确控制。Clarke变换将三相静止坐标系转换为两相静止坐标系,减少变量数量;Park变换进一步将两相静止坐标系转换为两相旋转坐标系,实现交流量到直流量的转换。文章提供了两种变换的数学公式、物理意义图解及C语言实现代码,并简要介绍了逆变换过程。这些变换为电机控制提供了关键的数学基础,后续将结合GD32F303的FPU特性进行优化实现。

汽车电子软件领域知识分享 189

[SCU 4494] 双剑合并 (xor字典树)

SCU - 4494 给定两个序列,问从两个序列中各取一个值的异或和最大为多少 把 A序列中的数字看成一个二进制的 01串,然后存到 Trie树里 然后将 B序列的数字同样看成一个 01串,然后在 Trie树上从高位到低位贪心地查找 如果B序列中查找的 01串当前位为 0,则找 Trie树上为 1的子儿子 否则就只能走为 0的右儿子,反之亦然,然后往下走 时间复杂度 O(N)#inclu

MisDeer's blog 827

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

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

Find MaxXorSum 经典字典树求异或最大值

传送门:Find MaxXorSum题目大意给出n个数,求在这n个数中取两个数使得他们异或最大解题思路非常经典利用字典树求异或的最大值。 读懂这个题目之后,对于初学者我们可能会思考下面的问题: 1. 两层循环o(n^2)肯定能求出了,但是肯定会超时 2. 这道题怎么做呢? 3. 思考一阵(在不知道用什么算法的情况下),会不会用把每个数转换为二进制,然后按位进行比对 4. 就算转换为二进制

woshinannan的专栏 4621

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

全球国家地区城市数据

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

【01trie合并】hdu 6191

一道广西邀请赛的题,赛场上想到了trie合并,但是没写过,算不清时间复杂度。于是迟迟没下去手 下来之后瞅了瞅感觉很简单啊,用递归+指针写了写,结果MLE+RE到绝望。 最后改成了非递归终于勉强过了orz。。。 题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6191 题意: 给一棵树,树上每个节点有权值,有q次询问,问

QuanQqqqq的博客 865

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

[后缀数组][trie合并][启发式合并][并查集] LOJ #6198. 谢特

SolutionSolutionSolution 求出后缀数组heightiheighti\text{height}_i后。 问题转化为maxi≠j{mini&lt;k≤j{heighti}+(wi&nbsp;xor&nbsp;wj)}maxi≠j{mini&lt;k≤j{heighti}+(wi&nbsp;xor&nbsp;wj)}\text{max}_{i\neq j}\{\text{mi...

Vectorxj的博客 647

【模拟试题】最大Xor路径 Trie

题目描述   MT神牛非常喜欢出Xor的题,在WC2011的时候,MT神牛出了一道非常经典的Xor最大路径题。   Bird向MT神牛学习,思考了许多关于Xor路径的问题,有一天,Bird想到了一个问题,给出一个序列,求这个序列的连续子序列的Xor值最大。   如1 3 4 8,最大的Xor子序列当然是3 xor 4 xor 8=15了。  ...

a15063149271的博客 280

9.27 不正常国家 Trie + 启发式合并

题意:   每个点有一个点权, 每个点u定义一个繁忙程度, 为u子树里面两点之间的路径异或和最大的两点的异或和. 这两点的lca必须要是u. 输出每个点的繁忙程度. 题解    x, y的路径异或和就是x到根的异或和 异或 y到根的异或和 再异或lca的值. 对于异或和01trie不太懂得: Click Here 这道题烦就烦在必须要是子树里面的两点, 这样普通的trie或

Le Petit Prince 676

"trie"(字典树) 和 "异或" 的一些性质

目录 异或性质: 没有的性质: 构造完二进制数 后 查找 数字 x 的最大异或: 更进一步的 CodeForces - 1055F Tree and XOR (HDU6625 three arrays ————01 trie + 贪心) 异或性质: 可以求前缀和, 我们想知道a[L] ^ a[L+1] ^ ... ^ a[R] 可以用一个 xor数组记录 , xor[i] = ...

我歌月徘徊,我舞影零乱 1156

二进制trie树解异或最大值问题

trie树一般可以用于查找与指定值最近的,而二进制trie树因为每个节点最多有两个子节点,所以也可以查找与指定值最远的值,即异或最大值。

zgottingen的专栏 3221

模拟退火算法 POJ 2420

【前言】先说一说什么是模拟退火,感觉很多地方都讲得挺神秘的,其实非常简单。 【模拟退火算法】转自点击打开链接 1. 模拟退火算法认识      爬山算法也是一个用来求解最优化问题的算法,每次都向着当前上升最快的方向往上爬,但是初始化不同可能    会得到不同的局部最优值,模拟退火算法就可能跳出这种局部最优解的限制。模拟退火算法是模拟热力学系统    中的退火过程。在退火过程中是

I good vegetable a! 3076

POJ 3074 DLX精确覆盖求解数独问题

【解题方法】             DLX解决9*9的数独问题,转化为729*324的精确覆盖问题             行:                   一共9 * 9 * 9 == 729行。一共9 * 9小格,每一格有9种可能性(1 - 9),每一种可能都对应着一行。             列:                   一共(9 + 9 + 9)

I good vegetable a! 1557

51 nod 1376 最长递增子序列的数量(二维偏序cdq)

【题意】求一个序列中LCS的数量? 【解题方法1】f[i]:以第i个数结尾的LCS的长度,和该长度的LIS的数量,转移的话,显然f[i].first=max(f[j].first)+1,j 【AC代码】 //51nod //LCS CDQ/BIT #include #include #include #include #include using namespace std; co

I good vegetable a! 1366

BZOJ 4653: [Noi2016]区间

Description 在数轴上有 n个闭区间 [l1,r1],[l2,r2],...,[ln,rn]。现在要从中选出 m 个区间,使得这 m个区间共同包含至少一个位置。换句话说,就是使得存在一个 x,使得对于每一个被选中的区间 [li,ri],都有 li≤x≤ri。 对于一个合法的选取方案,它的花费为被选中的最长区间长度减去被选中的最短区间长度。区间 [li,ri] 的长度定义为 ri−

I good vegetable a! 1181

线段树离线 SWUST OJ 2459 Submissions of online judge

【题意】维护一个区间不同的数的个数。 【解题方法】首先我们把所有查询区间记录下来,然后按照区间的右值排序,接着从左到右把每一个数更新到线段树中,并记录它出现的位置。如果一个数已经出现过,那么我们就把他上次出现的位置的值置为0,并更新它出现的位置。因为我们的查询区间是按右值排序的,因此把过去重复出现的数字置为0不会影响结果。当更新到某个区间的右值时,我们就查询一次该区间的答案,并把答案记下来。最后

I good vegetable a! 1098

Uva Recurrences 矩阵优化

Consider recurrent functions of the following form:f(n) = a1f(n − 1) + a2f(n − 2) + a3f(n − 3) + … + adf(n − d), for n > d, where a1, a2, … , ad are arbitrary constants. A famous example is the Fibon

I good vegetable a! 1076

HUST 1017 Exact cover(舞蹈链 入门题)(模板记录)

【题意】不解释了,就是裸的DLX模板题,先记录一下DLX的板子,看了半天总算理解了一些。 【DLX学习】参考这篇博客:点击打开链接 写得非常清楚,顺便赞一句,DLX真的是太神奇了。orz。 【AC 代码 DLX 模板】 /********************/ //Created by just_sort 2016/8/13 //All Rights Reserved. //Dancin

I good vegetable a! 1061
上一篇: 单词替换 KMP 简单应用
下一篇: POJ 3744 Scout YYF I
just_sort
博客等级 码龄11年 2360粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值