mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P5657 格雷码
R42138685
This commit is contained in:
parent
dc8ef4784b
commit
823693a42b
19
problem/P5657/P5657.cpp
Normal file
19
problem/P5657/P5657.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned long long n, k;
|
||||
cin >> n >> k;
|
||||
while ((--n) + 1) {
|
||||
if ((1ull << n) - 1 < k) {
|
||||
printf("1");
|
||||
k = (1ull << n) - k + (1ull << n) - 1;
|
||||
}
|
||||
else {
|
||||
printf("0");
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user