F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

位运算

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 604    Accepted Submission(s): 470


Problem Description
小丁最近对位运算很感兴趣,通过学习,他知道了按位与 $\otimes$,按位异或 $\oplus$,以及按位或 $\ominus$ 三种常见位运算。

按位与 $\otimes$:二进制下每一位做与,即 $0\otimes 0=0,0\otimes 1=0,1\otimes 0=0,1\otimes 1=1$。

按位异或 $\oplus$:二进制下每一位做异或,即 $0\oplus 0=0,0\oplus 1=1,1\oplus 0=1,1\oplus 1=0$​。

按位或 $\ominus$:二进制下每一位做或,即 $0\ominus 0=0,0\ominus 1=1,1\ominus 0=1,1\ominus 1=1$。

现在,对于一个在 $[0,2^k)$ 中的整数 $n$,小丁想要知道,有多少组也在 $[0,2^k)$ 中的整数 $a,b,c,d$,满足:
$$
a\otimes b\oplus c\ominus d=n
$$

注意,运算符是从左往右依次顺序结合的,即可以认为原表达式为:
$$
(((a\otimes b)\oplus c)\ominus d)=n
$$
 

Input
本题单个测试点内包含多组测试数据。

第一行一个整数 $ T(1\leq T\leq 10) $,表示数据组数。

对于每组数据,一行两个整数 $n,k$ $(1\leq k\leq 15,0\leq n<2^k)$。
 

Output
对于每组数据输出 $q$ 行,每行一个整数表示答案。
 

Sample Input
3 1 2 3 3 5 4
 

Sample Output
48 576 2304
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-09-20 04:00:30, Gzip enabled