发现值域很小,而且怎么异或都不会超过1023……然后可以使用类似基数排序的思想,每次扫一遍就行了。

复杂度O(k*1024)。

#include<cstdio>
#include<cstring>
using namespace std;
int n,k,x,cnts[1110],tmpcnts[1110];
int main()
{
// freopen("c.in","r",stdin);
int X;
scanf("%d%d%d",&n,&k,&x);
for(int i=1;i<=n;++i)
{
scanf("%d",&X);
++cnts[X];
}
for(int i=1;i<=k;++i)
{
memset(tmpcnts,0,sizeof(tmpcnts));
int now=0;
for(int j=0;j<=1023;++j)
{
int t=cnts[j];
if(now%2==0)
{
cnts[j]/=2;
tmpcnts[j^x]+=(t-cnts[j]);
}
else
{
cnts[j]=(cnts[j]+1)/2;
tmpcnts[j^x]+=(t-cnts[j]);
}
now+=t;
}
for(int j=0;j<=1023;++j)
cnts[j]+=tmpcnts[j];
}
for(int i=1023;i>=0;--i)
if(cnts[i])
{
printf("%d ",i);
break;
}
for(int i=0;i<=1023;++i)
if(cnts[i])
{
printf("%d\n",i);
break;
}
return 0;
}

最新文章

  1. Linux及VMWare的网卡选择设计及理解
  2. 8.3 使用Fluent API进行属性映射【Code-First系列】
  3. HQL查询——HQL查询的基本用法
  4. bootstrap总结
  5. Ubuntu16.04 安装配置Caffe
  6. HTML DOM 对象简单介绍
  7. (准备写)URAL1824 Ifrit Bomber 题解
  8. Codeforces 677E Vanya and Balloons(DP + 一些技巧)
  9. linux系统下yum源的搭建
  10. 下拉菜单得经典写法html5
  11. c#对字符串的各种操作
  12. Berkeley DB基础教程
  13. gets函数完美替代
  14. 查看死锁原因 /data/anr/traces.txt
  15. 在Linux终端下使用代理访问网络(转)
  16. mybatis返回int类型报null
  17. OO第二单元作业分析
  18. SSH(Spring SpringMVC Hibernate)框架整合
  19. Use MusicBrainz in iOS(三)查询专辑的完整信息
  20. Linux 平台和 Windows平台下 Unicode与UTF-8互转

热门文章

  1. JAVA List 一边遍历一边删除元素
  2. API网关Kong部署和使用文档
  3. POJ1459:Power Network(多源点多汇点的最大流)
  4. C# Producer Consumer (生产者消费者模式)demo
  5. 【BZOJ】1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
  6. autoKeras入门
  7. 【git】git提交忽略不必要的文件或文件夹
  8. How to learn wxPython
  9. WScript.Shell对象的 run()和exec()函数使用详解
  10. web页面的点对点复制粘贴