mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:51:58 +00:00
A. Cirno's Perfect Bitmasks Classroom
https://codeforces.com/contest/1688/submission/159441503
This commit is contained in:
parent
b37e815f77
commit
c582e56ee3
32
Codeforces/1688/A/A.cpp
Normal file
32
Codeforces/1688/A/A.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user