#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; const int maxn=;
long long X,K;
long long basex[maxn];
long long basek[maxn];
int totx,totk; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld",&X,&K); totx=totk=;
memset(basex,,sizeof basex);
memset(basek,,sizeof basek); while(X)
{
basex[totx++]=X%;
X=X/;
}
while(K)
{
basek[totk++]=K%;
K=K/;
} int now=;
for(int i=;i<totk;i++)
{
for(int j=now;;j++)
{
if(basex[j]==)
{
basex[j]=basek[i];
now=j+;
break;
}
else
{
basex[j]=;
now=j+;
}
}
}
for(int i=now;i<=;i++)
if(basex[i]==) basex[i]=; long long ans=;
for(int i=;i<=;i++) ans=ans+(long long)(basex[i]*pow(2.0,i));
printf("%lld\n",ans);
}
return ;
}

计算机学院大学生程序设计竞赛(2015’12) 1005 Bitwise Equations的更多相关文章

  1. 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排

    1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  2. hdu 计算机学院大学生程序设计竞赛(2015’11)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  3. 计算机学院大学生程序设计竞赛(2015’12)Study Words

    Study Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  4. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  5. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  7. 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

  8. 计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix

    #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle

    #include<cstdio> #include<algorithm> using namespace std; using namespace std; +; int a[ ...

随机推荐

  1. Ubuntu DNS bind9 配置

    下面的配置就是实现解析test.zp.com到不同的IP地址 安装dns server软件包$ apt-get install bind9 配置dns配置文件的路径在/etc/bind路径下面添加一个 ...

  2. caffe的matlab接口一览表

    blob 简述 方法: shape reshape get_diff set_diff 私有方法: check_and_preprocess_shape check_and_preprocess_da ...

  3. eclipse添加桌面快捷方式

    linuxmint系统 输入sudogedit /usr/share/applications/eclipse.desktop,在打开的文件中输入以下参数: [Desktop Entry] Encod ...

  4. NET:交换机的背板带宽,交换容量,包转发率区别

    交换机的背板带宽,交换容量,包转发率区别 背板带宽指的是背板整个的交换容量,交换容量指cpu的交换容量,包转发指的是三层转发的容量 一.背板带宽 1.交换机背板带宽含义 交换机的背板带宽也叫背板容量, ...

  5. perl命令+关键字

    来源: http://www.cnblogs.com/itech/archive/2012/11/01/2749666.html http://www.garybeene.com/vb/tut-per ...

  6. Android编译环境(1) - 编译Native C的模块

    Android编译环境本身比较复杂,且不像普通的编译环境:只有顶层目录下才有Makefile文件,而其他的每个component都使用统一标准的Android.mk. Android.mk文件本身是比 ...

  7. hibernate ——联合主键

    接上一篇博客:http://www.cnblogs.com/tengpan-cn/p/5551323.html 主键类不需要写任何注解,表对象类使用@IdClass注解 在表对象类前面加@IdClas ...

  8. 全文检索工具推荐FileLocator

    全文检索工具推荐FileLocator https://www.baidu.com/link?url=_vaDZaJ_OePrAX-BTUD5hjTymnvN7_1oIAnWyS25hqxAg0nUH ...

  9. jdk,tomcat配置

    方法/步骤 一.安装JDK和Tomcat 1,安装JDK:直接运行jdk-7-windows-i586.exe可执行程序,默认安装即可. 备注:路径可以其他盘符,不建议路径包含中文名及特殊符号. 2. ...

  10. 快学Scala-第一章 基础

    知识点: Scala程序并不是一个解释器,实际发生的是,你输入的内容被快速的编译成字节码,然后这段字节码交由Java虚拟机执行. 以val定义的值是一个常量,以var定义的值是一个变量,声明值或变量但 ...