比赛 NOIP模拟赛1 评测结果 AAATTTTTTT
题目名称 异或 最终得分 30
用户昵称 Tony 运行时间 7.012 s
代码语言 C++ 内存使用 3.30 MiB
提交时间 2018-02-08 20:32:27
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int RD(){
	int flag = 1,out = 0;char c = getchar();
	while(c < '0' || c > '9'){if(c == '-')flag = -1;c = getchar();}
	while(c >= '0' && c <= '9'){out = out * 10 + c - '0';c = getchar();}
	return flag * out;
	}
const int maxn = 1000100;
int a[maxn];
int num,k;
priority_queue<int>Q;
int main(){
	freopen("xorxor.in","r",stdin);
	freopen("xorxor.out","w",stdout);
	num = RD();k = RD();
	for(int i = 1;i <= num;i++){
		a[i] = RD();
		}
	for(int i = 1;i <= num;i++){
		for(int j = i + 1;j <= num;j++){
			int v = a[i] ^ a[j];
			//cout<<v<<endl;
			Q.push(v);
			if(Q.size() > k)Q.pop();
			}
		}
	cout<<Q.top()<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
	}