题目链接:
在2^k维空间中构造2^k个相互垂直的向量.
观察给出的数据, 无限脑洞...
AC代码:
#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"#include "queue"#include "stack"#include "cmath"#include "utility"#include "map"#include "set"#include "vector"#include "list"#include "string"#include "cstdlib"using namespace std;typedef long long ll;const int MOD = 1e9 + 7;const int INF = 0x3f3f3f3f;int n;int main(int argc, char const *argv[]){ scanf("%d", &n); n = 1 << n; for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) printf("%c", __builtin_parity(i & j) ? '*' : '+'); printf("\n"); } return 0;}
列举四个位运算函数:
- int __builtin_ffs (unsigned int x) 返回x的最后一位1的是从后向前第几位,比方7368(1110011001000)返回4。
- int __builtin_clz (unsigned int x) 返回前导的0的个数。
- int __builtin_ctz (unsigned int x) 返回后面的0个个数,和__builtin_clz相对。
- int __builtin_popcount (unsigned int x) 返回二进制表示中1的个数。
- int __builtin_parity (unsigned int x) 返回x的奇偶校验位,也就是x的1的个数模2的结果。
- 摘自: