第一题关键就是两部分,先是交换位置: `((input & 0x55555555) << 1) | ((input & 0xaaaaaaaa) >> 1);` 然后移位: uint32_t left = 0, now = 0; for (uint32_t i = 0; i < V.size(); ++i) { now = V[i] & 0x00000003; V[i] = (V[i] >> 2) | (left << 30); left = now; } V[0] = V[0] | (left << 30); 直接cout就行
3 2

相关推荐

牛客网
牛客企业服务