当前位置: 首页 > news >正文

高性能网站建设指南 京东浙江壹设软装设计有限公司

高性能网站建设指南 京东,浙江壹设软装设计有限公司,上海网站建设选缘魁-企查,源码哥网站的模板今天学习了神奇的线性基#xff0c;主要是在解决异或问题时比较有用。 详细的解释和证明有大佬珠玉在前#xff0c;如果感兴趣可以移步 补充一下自己的理解#xff1a; 可以联系线性代数极大无关组进行理解#xff0c;线性基就相当于异或的向量空间中的极大无关组#xff…今天学习了神奇的线性基主要是在解决异或问题时比较有用。 详细的解释和证明有大佬珠玉在前如果感兴趣可以移步 补充一下自己的理解 可以联系线性代数极大无关组进行理解线性基就相当于异或的向量空间中的极大无关组线性代数中的是加减的向量空间因此线性基有极大无关组的性质 向量的个数一定可以表示向量空间内任意一个向量向量空间中不包括零向量 但是我们在计算线性基的时候为什么要从最高位开始选呢这其实只是为了方便使用相当于我们在求极大无关组的时候习惯于从左往右进行初等变换的习惯一样。同样的我们也可以从低位开始选也是不会影响的可是这样选出来不方便我们使用从高位到低位方便求最大值最小值 在求第K大的时候我们还需要对线性基进行重建这相当将行阶梯形阵变换为行最简形矩阵一样。 这样我们就可以从大往小依次找出第k大。可能会疑惑为什么不考虑后面的1的影响只考虑最高位1的影响就可以呢因为高位的1的影响更大高位有1没1的影响大于后面那些数字的影响所以只考虑高位的影响就可以。 这里给出模板题的代码。 【题目描述】 XOR is a kind of bit operator, we define that as follow: for two binary base number A and B, let CA XOR B, then for each bit of C, we can get its value by check the digit of corresponding position in A and B. And for each digit, 1 XOR 1 0, 1 XOR 0 1, 0 XOR 1 1, 0 XOR 0 0. And we simply write this operator as ^, like 3 ^ 1 2,4 ^ 3 7. XOR is an amazing operator and this is a question about XOR. We can choose several numbers and do XOR operatorion to them one by one, then we get another number. For example, if we choose 2,3 and 4, we can get 2345. Now, you are given N numbers, and you can choose some of them(even a single number) to do XOR on them, and you can get many different numbers. Now I want you tell me which number is the K-th smallest number among them. Input First line of the input is a single integer T(T30), indicates there are T test cases. For each test case, the first line is an integer N(1N10000), the number of numbers below. The second line contains N integers (each number is between 1 and 10^18). The third line is a number Q(1Q10000), the number of queries. The fourth line contains Q numbers(each number is between 1 and 10^18) K1,K2,…KQ. Output For each test case,first output Case #C: in a single line,C means the number of the test case which is from 1 to T. Then for each query, you should output a single line contains the Ki-th smallest number in them, if there are less than Ki different numbers, output -1. Sample Input 2 2 1 2 4 1 2 3 4 3 1 2 3 5 1 2 3 4 5Sample Output Case #1: 1 2 3 -1 Case #2: 0 1 2 3 -1【AC代码】 #includecstdio #includecstring #includeiostream #includealgorithm #includevector #includequeue #includeset #includeclimits #includecstdlib #includecmathusing namespace std;typedef long long ll;const int MAXN10005; int n,q; ll k,tmp; struct L_B {ll b[65],p[65];int cnt,flag;L_B(){memset(p,0,sizeof(p));memset(b,0,sizeof(b));cntflag0;}inline bool insert(ll x){for(int i62;i0;--i)if(x(1lli)){if(b[i])x^b[i];else{b[i]x;return true;}}flag1;return false;}ll get_max(){ll ret 0;for(int i62;i0;--i)if((ret^b[i])ret)ret^b[i];return ret;}ll get_min(){if(flag)return 0;for(int i0;i62;i)if(b[i])return b[i];return 0;}inline void rebuild(){for(int i 1;i 62;i)if(b[i])for(int j0;ji;j)if(b[i](1llj))b[i]^b[j];for(int i0;i62;i)if(b[i])p[cnt]b[i];}ll kth(ll k){if(flag)--k;if(k0)return 0;ll ret 0;if(k(1llcnt))return -1;for(int i0;icnt-1;i)if(k(1lli))ret^p[i];return ret;} }; /* L_B merge(const L_B n1,const L_B n2) {L_B ret n1;for(int i 0;i 62;i)if(n2.b[i])ret.insert(n2.b[i]);ret.flag n1.flag | n1.flag;return ret; } */ int main() {int T;scanf(%d,T);for(int Case1;CaseT;Case){L_B lis;scanf(%d,n);for(int i 1;i n;i){scanf(%lld,tmp);lis.insert(tmp);}scanf(%d,q);lis.rebuild();printf(Case #%d:\n,Case);while(q--){scanf(%lld,k); printf(%lld\n,lis.kth(k));}}return 0; }
http://www.zqtcl.cn/news/386007/

相关文章:

  • spoc课程网站建设专业彩票网站建设
  • 创建网站需要注意什么忻州市城乡建设管理局网站
  • 万江做网站wordpress 动静
  • 北京自助模板建站遂宁企业网络推广方案
  • 湖南建设科技节能协会网站武夷山景区网站建设特点
  • 那些网站建设的好百度搜索风云排行榜
  • 网站开发 模板 c沈阳市建设工程质量检测中心网站
  • 企业网站设计专业好吗做钓鱼网站要具备什么
  • 广西备案工信部网站用asp.net做后台网站
  • 静态网站漏洞wordpress 外卖
  • 暗网做网站温州做网络推广的公司
  • 网站描述 修改上海火迎网络推广运营优化
  • 黄石网站建设哪家专业做个网站费用
  • 免费做的网站怎么设置域名解析宁夏百度seo
  • 化妆品产品的自建网站有哪些阿里云cdn wordpress错位
  • 增加网站流量网站新闻字体
  • 做外贸建网站需要推广吗服装如何做微商城网站
  • 上海市建设安全协会网站查询考试伪静态 wordpress
  • 网站免费建站o网站编程多少钱
  • 建设网站开发海外推广服务
  • 网站建设需要提供的资料文档营销平台建设
  • 做个响应式网站多少钱河南网络推广系统
  • wordpress的后台文章图文发布清远市seo广告优化
  • 长沙的互联网网站公司招标文件免费下载网站
  • icp备案系统网站品网站建设公司排名
  • 什么网站可以做音乐相册可信的品牌网站建设
  • 洛阳网站建设优惠公司网站查询ip地址
  • 学校网站模版电影网站要怎样做才有出路
  • 无锡网站建设 微信企业网站建设与管理期末考试
  • 海南海口网站开发公司怎么建立微网站?