# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141772 | mohyay | cmp (balkan11_cmp) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
#define pb push_back
#define pF first
#define pS second
#define SP <<' '<<
ll bits[112345];
void bit_set(ll i) {bits[i] = 1; return;}
ll bit_get(ll i) {return (bits[i] == 0 ? 0 : 1);}
void remember(int a) {
unsigned int n = a;
if (popcount(n) <= 6) {
ll j = 2048;
ll i = 12;
while (n > 0) {
if (n >= j) {
n -= j;
bit_set(i);
}
j/=2;
i--;
}
}
else {
bit_set(100);
ll j = 2048;
ll i = 12;
while (n > 0) {
if (n >= j) {
n -= j;
}
else bit_set(i);
j/=2;
i--;
}
}
return;
}
int compare(int b) {
ll n = b;
ll neg = bit_get(100);
ll cmp1 = 1;
if (neg == 0) {
ll j = 2048;
ll i = 12;
while (i > 0) {
ll x = bit_get(i);
if (n >= j) {
n -= j;
if (x == 0) {cmp1 = 0; break;}
}
else if (x == 1) {cmp1 = 2; break;}
j /= 2;
i--;
}
}
else {
ll j = 2048;
ll i = 12;
while (i > 0) {
cout << n << endl;
ll x = bit_get(i);
if (n >= j) {
n -= j;
if (x == 1) {cmp1 = 0; break;}
}
else if (x == 0) {cmp1 = 2; break;}
j /= 2;
i--;
}
}
if (cmp1 == 2) return -1;
if (cmp1 == 1) return 0;
return 1;
}
int main() {
remember(1975);
cout<<compare(1536);
}