0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:11:59 +00:00

A. Cirno's Perfect Bitmasks Classroom

https://codeforces.com/contest/1688/submission/159441503
This commit is contained in:
Baoshuo Ren 2022-06-04 17:25:25 +08:00
parent b37e815f77
commit c582e56ee3
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

32
Codeforces/1688/A/A.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int t, x, y;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t;
while (t--) {
cin >> x;
int k = 0;
while (!((x >> k) & 1) && k <= 30) k++;
y = 1 << k; // 此时满足 (x & y) > 0
if ((x ^ y) <= 0) {
int k = 0;
while (((x >> k) & 1) && k <= 30) k++;
y += 1 << k; // 此时满足 (x ^ y) > 0
}
cout << y << endl;
}
return 0;
}