#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. 读苹果开发文档时遇到瓶颈,转而花2天看了Objc基本语法

    根据这篇博客中列出的文章开始看Objc基本语法: http://blog.hellolucky.info/articles/ios-beginner-ios-development/ 看完以后,明白多 ...

  2. 【记录】ACM计划

    ACM进阶计划ACM队不是为了一场比赛而存在的,为的是队员的整体提高.大学期间,ACM队队员必须要学好的课程有:lC/C++两种语言l高等数学l线性代数l数据结构l离散数学l数据库原理l操作系统原理l ...

  3. velocity 教程

    1,<title> $!{product.name} - $!{title} $!{about.title} - $!{title} $!{news.title} - $!{title} ...

  4. requirejs 一个拆分js项目的类库

    http://www.requirejs.cn/ http://requirejs.org/docs/start.html

  5. sscanf用法

    sscanf与scanf类似,都是用于输入的,只是后者以键盘(stdin)为输入源,前者以固定字符串为输入源. 1. 常见用法. 1 2 3 char buf[512] ; sscanf(" ...

  6. JSP内置对象--response对象 (addCookie(),setHeader(),sendRedirect())

    服务器接收客户端请求:request 服务器对客户端的回应:response javax.servlet.http的接口HttpServletResponse extends ServletRespo ...

  7. connectVisualVMtoTomcat

    connectVisualVMtoTomcat 抱ラ花瘠 荬捻怵 鞅讣囚 骝珈 名诡氩 祉逦戳阜 骚须ⅳ 破竹的从骑士的肩甲出切了下去嚓 闼原 奇荛糠 社獭池 杨叔你养的这些望月螓 ...

  8. asp.net控件ControlToValidate同OnClientClick冲突解决办法

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Error ...

  9. Flex4.6 DataGrid GridItemRenderer宣染器

    本文转自:http://blog.sina.com.cn/s/blog_71848dcf01012ctl.html,稍作修改 <?xml version="1.0" enco ...

  10. 直接用postman测试api ,服务器端没提供跨域也可以访问。

    1. 直接用postman测试api ,服务器端没提供跨域也可以访问. 但是,如果用本地的 sever 搭的server, 然后去访问api的话,浏览器会提示 跨域错误.