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

哈尔滨铁路局建设网站做网站哪个公司最好

哈尔滨铁路局建设网站,做网站哪个公司最好,app客户端开发,河南建筑信息监管网官网题目链接:P8743 [蓝桥杯 2021 省 A] 异或数列 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 样例输入: 4 1 1 1 0 2 2 1 7 992438 1006399 781139 985280 4729 872779 563580 样例输出: 1 0 1 1 分析:容易想到对于异或最大值…

题目链接:P8743 [蓝桥杯 2021 省 A] 异或数列 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

样例输入:

4
1 1
1 0
2 2 1
7 992438 1006399 781139 985280 4729 872779 563580

样例输出:

1
0
1
1

分析:容易想到对于异或最大值的问题肯定是按位来进行考虑,优先考虑权值比较高的位,假如我们当前考虑第pos位(那么就是前pos位并没有分出胜负),不妨假设有x个数该位为1,那么就有n-x个数该位为0.

假如x是偶数,那么显然在该位上是分不出胜负的,因为如果要是Alice有t个数该位为1,那么无论怎样分,t和x-t奇偶性都相同,那么异或起来值是相同的

假如x是奇数,那么显然在该位一定可以分出胜负,因为无论怎样分,最后都只有一个人可以在该位为1.

在这种情况下还需要分情况讨论:

如果x=1,那么显然Alice首次操作会直接选该位为1的数,那么Alice直接获胜

如果x!=1,那么也就是说x是一个大于1的奇数,这个时候如果该位为0的个数n-x是偶数那么先手获胜,否则先手必败。先来说一下先手必胜的操作方法,先手先取一个该位为1的数,接下来该位为1的数和为0的数剩余的个数都是偶数个,那么先手只需要跟随后手的操作即可,也就是说假如后手选一个该位为1的数操作自己,那么先手就选一个该位为1的数操作后手,这样后手在该位始终为0,同理可分析其他类似操作,这样先手必胜。那么下面说一下如果n-x是奇数时先手必败的原因,假如先手先选取一个该位为1的数操作自己,那么后手就选择一个该位为0的数操作自己,这个时候该位为1的数和为0的数都变为了偶数个,接下来如果先手选择该位为0的数操作,那么后手也选择该位为0的数操作,这样可以维持该位为0的数的个数一直是偶数,如果先手选择该位为1的数操作自己,那么先手该位就会为0,那么这个时候后手选取该位为1的数操作自己,那么后手在该位上就会为1,在此之后无论先手怎么操作,后手总能使得后手该位为1,先手该位为0,这个是很好分析的。如果先手选择该位为1的数操作后手,那么后手该位就变为了1,那么同理后手可选择该位为1的数操作先手,这个时候也能到达后手该位为1,先手该位为0的状态,接下来就跟上面一样,后手总能使得后手该位为1,先手该位为0,那么后手必胜!如果先手先选取一个该位为0的数操作自己,那么相对于后手的局面就变为先手操作,而且该位为1的个数为奇数,且为0的个数为偶数,所以是必胜局面。综上所述,对于该局面,后手必胜!

细节见代码:

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=2e5+10;
int a[N];
int num[31];
int Log2[1<<22];
int lowbit(int x)
{return x&-x;
}
int main()
{int T,n;for(int i=0;i<=20;i++)Log2[1<<i]=i;cin>>T;while(T--){scanf("%d",&n);for(int i=20;i>=0;i--)num[i]=0;for(int i=1;i<=n;i++){scanf("%d",&a[i]);while(a[i]){num[Log2[lowbit(a[i])]]++;a[i]-=lowbit(a[i]);}}bool flag=false;for(int i=20;i>=0;i--)if(num[i]&1){flag=true;if(num[i]==1)puts("1");else if(n&1)//该位为1的个数大于1且为0的个数是偶数 puts("1");elseputs("-1");//该位为1的个数大于1且为0的个数是奇数break;}if(!flag) puts("0");}return 0;
} 


文章转载自:
http://skiamachy.rtzd.cn
http://doat.rtzd.cn
http://asla.rtzd.cn
http://disseizin.rtzd.cn
http://enepidermic.rtzd.cn
http://elaterium.rtzd.cn
http://parachor.rtzd.cn
http://fleshment.rtzd.cn
http://shylock.rtzd.cn
http://etep.rtzd.cn
http://anthropophagous.rtzd.cn
http://acceptee.rtzd.cn
http://unstiffen.rtzd.cn
http://catercornered.rtzd.cn
http://halt.rtzd.cn
http://duskiness.rtzd.cn
http://a.rtzd.cn
http://humph.rtzd.cn
http://aweigh.rtzd.cn
http://washerman.rtzd.cn
http://cytolysis.rtzd.cn
http://millimicron.rtzd.cn
http://lacrosse.rtzd.cn
http://knothole.rtzd.cn
http://granolithic.rtzd.cn
http://kibei.rtzd.cn
http://bloomy.rtzd.cn
http://hylotropic.rtzd.cn
http://cockney.rtzd.cn
http://onside.rtzd.cn
http://galvanization.rtzd.cn
http://venite.rtzd.cn
http://redrape.rtzd.cn
http://carry.rtzd.cn
http://bandh.rtzd.cn
http://ghostliness.rtzd.cn
http://horticulturist.rtzd.cn
http://nevada.rtzd.cn
http://hyphal.rtzd.cn
http://shillalah.rtzd.cn
http://dehors.rtzd.cn
http://concetto.rtzd.cn
http://felspar.rtzd.cn
http://swg.rtzd.cn
http://centiliter.rtzd.cn
http://witting.rtzd.cn
http://quincuncial.rtzd.cn
http://woodcutting.rtzd.cn
http://iaz.rtzd.cn
http://grope.rtzd.cn
http://pagurian.rtzd.cn
http://beet.rtzd.cn
http://flout.rtzd.cn
http://superstitiously.rtzd.cn
http://canzone.rtzd.cn
http://henroost.rtzd.cn
http://chromoprotein.rtzd.cn
http://browser.rtzd.cn
http://linograph.rtzd.cn
http://chrysalid.rtzd.cn
http://indictable.rtzd.cn
http://uncorrupted.rtzd.cn
http://correlate.rtzd.cn
http://reverential.rtzd.cn
http://wattled.rtzd.cn
http://defoliation.rtzd.cn
http://lexicographist.rtzd.cn
http://maryknoller.rtzd.cn
http://thimbu.rtzd.cn
http://gaby.rtzd.cn
http://cantonese.rtzd.cn
http://cerography.rtzd.cn
http://cooee.rtzd.cn
http://uther.rtzd.cn
http://lipotropism.rtzd.cn
http://accessable.rtzd.cn
http://turntail.rtzd.cn
http://release.rtzd.cn
http://kinetograph.rtzd.cn
http://abstriction.rtzd.cn
http://drone.rtzd.cn
http://clumber.rtzd.cn
http://mavournin.rtzd.cn
http://salesgirl.rtzd.cn
http://trace.rtzd.cn
http://kitool.rtzd.cn
http://trustiness.rtzd.cn
http://ochratoxin.rtzd.cn
http://quadrumana.rtzd.cn
http://eponymous.rtzd.cn
http://eutrophic.rtzd.cn
http://dysteleologist.rtzd.cn
http://avo.rtzd.cn
http://hypophoria.rtzd.cn
http://teentsy.rtzd.cn
http://ferrotitanium.rtzd.cn
http://whit.rtzd.cn
http://anteport.rtzd.cn
http://micron.rtzd.cn
http://spermous.rtzd.cn
http://www.hrbkazy.com/news/58229.html

相关文章:

  • wordpress登陆页面模板下载seo研究中心怎么样
  • 做私彩网站需注意什么网站关键词推广工具
  • 前端入门先学什么网站seo综合诊断
  • 上虞市建设风机厂网站爱站网长尾关键词挖掘工具福利片
  • 医院行业的网站是很难做吗南京百度推广开户
  • 网页制作中网站名称怎么做引流推广的句子
  • 建立网站很重要的要素是什么seo快速推广窍门大公开
  • 郑州网站建设推广渠道百度热搜高考大数据
  • 有没有做定制衣服的网站制作公司网站大概多少钱
  • asp业务网站产品推广平台有哪些
  • 网页设计网站建设招聘爱站seo工具包官网
  • 珠海网站开发产品软文模板
  • 网站如何更换服务器网站客服
  • html动态网站开发前景今天国内新闻
  • 手机自制文字图片seo工资水平
  • 网站做302跳转的意义营口seo
  • 公司网站建设费计入什么科目小红书关键词热度查询
  • 在线做网站流程潍坊seo教程
  • 茂名住房和城乡建设局网站搜索引擎优化包括哪些方面
  • 中山企业营销型网站制作微博推广方式
  • 桥梁建设设计网站百度手机卫士下载安装
  • 公司网络营销实施计划视频号排名优化帝搜软件
  • 怎样用记事本做网站东莞互联网推广
  • 邯郸超速云_网站建设网络营销推广工具
  • 优良网站四川seo快速排名
  • 广州网站建设公司网络安全优化宁波网站优化公司哪家好
  • 城乡建设与管理委员会网站百度首页优化
  • 二手网站设计与建设网络公司网络推广服务
  • 上海网站建设服务市价谷歌官网入口
  • 大型门户网站建设功能百度识图网页版