#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. [tableView dequeueReusableCellWithIdentifier:CellIdentifier] 后面forIndexPath:indexPath参数的解释

    解决以下错误: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'u ...

  2. nginx php mysql 集成安装包

    经过多次的苦苦寻找,终于找到一款 集成了nginx 和mysql php的包.只需一键安装即可. 且可以修改其中的nginx mysql 与php的版本. 解压此文件lnmp???ɰ?n-1.6p-5 ...

  3. 老鸟需要知道的一些php系统类函数

    作为一个老手级别的php程序员,知道下面几个php系统级别的函数,不足为多吧!获取系统信息和调试程序的时候应该能用的上! PHP系统类函数 assert函数:检查assertion声明是否错误 ext ...

  4. Rsync数据远程同步备份

    rsync的使用方法 一.设置Rsync Server端 Rsync server需要设定四个方面: 1.规划建立备份目录区 2.设定: /etc/xinetd.d/rsync 3.设定: /etc/ ...

  5. perl的USE和require

    来源: http://www.cnblogs.com/itech/archive/2010/11/22/1884345.html 相同: 都可以用来引用module(.PM). 不同: 1) 区别在于 ...

  6. Boost的VS开发环境搭建

    1. 下载并解压Boost C++ Libs 下载地址: SourceForge:http://sourceforge.net/projects/boost/files/boost/1.48.0/ B ...

  7. android版本 busybox

    http://www.busybox.net/downloads/binaries/1.21.1/  根据不同的平台选择busybox已经编译好的

  8. JPA 系列教程3-单向多对一

    JPA中的@ManyToOne 主要属性 - name(必需): 设定"many"方所包含的"one"方所对应的持久化类的属性名 - column(可选): 设 ...

  9. 字符串编码问题(Ascii、Unicode、UCS-2、GBK、UTF-8)

    1.字符编码的发展 第一阶段:ASCII阶段,(American Standard Code for Information Interchange, "美国信息交换标准码),计算机当时只支 ...

  10. java 输入、输出流