hdu 3711
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int cmp(const void *a,const void *b) {
return *(int *)a-*(int *)b;
}
int seach(int n,int m) {
int sum=0,n_x,m_x;
while(n||m) {
n_x=n%2;
m_x=m%2;
n/=2;
m/=2;
if(n_x!=m_x)
sum++;
}
return sum;
}
int main() {
int i,j,n,m,a[1001],b[1001],min,ma,ma_x,t;
scanf("%d",&t);
while(t--) {
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
scanf("%d",&a[i]);
for(j=0;j<n;j++)
scanf("%d",&b[j]);
qsort(a,m,sizeof(a[0]),cmp);
for(i=0;i<n;i++) {
min=10000001;
for(j=0;j<m;j++) {
ma=seach(b[i],a[j]);
if(ma<min) {
min=ma;
ma_x=a[j];
} }
printf("%d\n",ma_x);
}
}
return 0;
}
hdu 3711的更多相关文章
- HDU 3711 Binary Number
Binary Number Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- [HDU] 3711 Binary Number [位运算]
Binary Number Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- hdu 3711 Binary Number(暴力 模拟)
Problem Description For non-negative integers x and y, f(x, y) , )=,f(, )=, f(, )=. Now given sets o ...
- HDU 1950(LIS)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1950 Bridging signals Time Limit: 5000/1000 MS (Java ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- codevs 3026 恶心的扑克
时间限制: 1 s 空间限制: 64000 KB 题目等级 : 白银 Silver 题目描述 Description 有一副恶心的扑克,从小到大依次是3 , 4 , 5 , 6 , 7 , 8 , ...
- Tunneling cannot be enabled without the local_ip bound to an interface on the host. Please configure local_ip 192.168.30.71 on the host interface to be used for tunneling and restart the agen
按照官方文档配置linux bridge 会出现一下问题 Tunneling cannot be enabled without the local_ip bound to an interface ...
- ConCurrent in Practice小记 (4)
ConCurrent in Practice小记 (4) Executors Callable && Future <T> Callable:此接口有一个call()方法. ...
- python之编码的进阶
识记点: ascii 不支持中文 gbk 国标 中文2 英文1 unicode 万国码 英文2 中文4 utf-8 英文1 欧洲2 亚洲3 硬盘中存储的是字节 用什么编码就用什么解码 # 一段文字的转 ...
- SQLyog连接数据库 提示错误plugin caching_sha2_password could not be loaded
1.打开mysql cmd 2.执行语句 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; # ...
- javase(4)_数组
一.数组概述 数组可以看成是多个相同类型数据组合,对这些数据的统一管理. 数组变量属于引用类型,数组也可以看成对象,数组中的每个元素相当于该对象的成员变量. 数组中的元素可以是任意类型,包括基本类型和 ...
- ECshop二次开发 ECSHOP首页显示积分商城里的商品
以ECSHOP2.7.2官方默认模板为基础 1).首先打开 index.php 文件,在最末尾增加下面函数,注意千万不要写到 “?>” 的外面去,要加在“?>”的前面,加以下代码: /** ...
- 2018年,最经典的26个JavaScript面试题和答案!
根据 Stack Overflow 的 2018 年度调查,JavaScript 连续六年成为最常用的编程语言.所以我们必须面对这样的现实,JavaScript 已经成为全栈开发技能的基石,在全栈开发 ...
- Kali入门配置使用(一)
一.Kali简介 1.1.相关连接 Kali百度百科:https://baike.baidu.com/item/Kali%20linux/8305689?fr=aladdin Kali wiki:ht ...
- perl学习之六:变量作用域
变量作用域 (一)包变量 $x = 1 这里,$x是个包变量.关于包变量,有2件重要的事情要了解: 1)假如没有其他申明,变量就是包变量:2)包变量总是全局的. 全局意味着包变量在每个程序里总可访问到 ...