首页 > 试题广场 >

【模板】位运算Ⅰ ‖ 整体与、或、异或

[编程题]【模板】位运算Ⅰ ‖ 整体与、或、异或
  • 热度指数:194 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1024M,其他语言2048M
  • 算法知识视频讲解
\hspace{15pt}对于给定的整数 x,y,依次输出它们按位或^\texttt{[1]}按位与^\texttt{[2]}按位异或^\texttt{[3]}的结果。

【名词解释】
\hspace{15pt}按位或^\texttt{[1]}(Bitwise OR):对两个整数的二进制表示按位进行或运算。
\hspace{15pt}按位与^\texttt{[2]}(Bitwise AND):对两个整数的二进制表示按位进行与运算。
\hspace{15pt}按位异或^\texttt{[3]}(Bitwise XOR):对两个整数的二进制表示按位进行异或运算。

输入描述:
\hspace{15pt}每个测试文件均包含多组测试数据。第一行输入一个整数 T\left(1\leq T\leq 10^5\right) 代表数据组数,每组测试数据描述如下:

\hspace{15pt}在一行上输入两个整数 x,y \left(0\leq x,y<2^{12}\right),表示初始整数。


输出描述:
\hspace{15pt}对于每组测试数据,新起一行,输出三个整数,表示按位或、按位与、按位异或的结果。
示例1

输入

3
16 12
0 255
31 255

输出

28 0 28
255 0 255
255 31 224
头像 周康禧
发表于 2025-12-04 16:58:19
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using PII=pair<ll,ll>; using PIII=pair< 展开全文
头像 小狐今天睡大觉
发表于 2025-12-14 02:54:27
#include <iostream> using namespace std; int main() { int n,a,b; cin>>n; while(n--){ cin>>a>>b; c 展开全文
头像 牛客用户098471297
发表于 2025-11-28 14:18:54
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define quick ios::sync_with_stdio(false);cin.tie(0);cout.t 展开全文