位运算

C. The Very Beautiful Blanket

2023-03-1719:13:29

性质:两个相同的数异或等于0
用类似的性质例如
000000011
100000011
100000010
000000010
构造这样的四个数
c++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

int main() {
ios::sync_with_stdio(
false), cin.tie(0), cout.tie(0);
int T = 1;
cin
>> T;
while (T--)
{
int n, m;
cin
>> n >> m;
cout
<< n * m << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cout
<< (j + (1 << 8) * (i - 1)) << " ";
}
cout
<< endl;
}
}
return 0;
}

 

posted @ 2023-03-17 19:19  zhujio  阅读(16)  评论(0编辑  收藏  举报