最近一段时间杭电10点就打烊了!题目链接就不上了;
很长一段时间没有更新博客了!最近一段时间会陆陆续续的将近期做过的一些题目分享出来,也是为了勉励自己!
Description
Input
Output
Sample Input
2 2 5 1 2 1 2 3 4 5 5 2 1000000 9999 1423 3421 0 13245 353
Sample Output
1 2 1 1 1 9999 0
题目大意:
就是给我们两个集合A和B要我们用A中的每个元素去匹配B中的每个元素,得到其中元素二进制不同的数的个数最小的那个!
举个栗子就懂了:比如第一组数据集合A为的元素为(1,2),B的元素为(1,2,3,4,5)
将其中元素转换成而二进制数看看 :
1 -> 0001
2 -> 0010
3 -> 0011
4 -> 0100
5 -> 0101
那么我们可以看书,(Ai,B1)(i=0,1....代表A集合数组的下边)中(1,1)二进制位不同的个数为 0;(2,1)中二进制位不同的个数为 1;那么个数最小的就是匹配到A1的时候,所以第一个样例的输出结果就是 1:;
#include
#include
#include
using namespace std;
//const int mINF=0XFFFFFFFF;
int a[1005],b[1005];
int fc(int x,int y)
{
int count=0;
while(1)
{
if((x&1)!=(y&1))count++;
x=x>>1;
y=y>>1;
if(x==0&&y==0)return count;
}
}
long long fmint,post;
int main()
{
// cout<<(1&1)<>T;
while(T--)
{
int n,m;
cin>>m>>n;
for(int i=0;i>a[i];
for(int i=0;i>b[i];
sort(a,a+m);
for(int i=0;it)fmint=t,post=j;
}
cout<