# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205035 | alexandra_udristoiu | cmp (balkan11_cmp) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include "cmp.h"
using namespace std;
int v[] = {0, 10, 10, 8, 6};
int p[] = {0, 6400, 640 ,64 ,6, 1}
void remember(int a){
for(int i = 4; i >= 1; i--){
bit_set(a);
a /= v[i];
}
}
int compare(int b){
int i, x, st, dr;
for(i = 1; i <= 4; i++){
x = b / p[i + 1];
if(get_bit(x) == 0){
break;
}
}
if(i == 5){
return 0;
}
st = x - x % v[i];
dr = st + v[i] - 1;
if(x - st < dr - x){
for(i = st; i < x; i++){
if(get_bit(i) == 1){
return 1;
}
}
return -1;
}
else{
for(i = dr; i > x; i--){
if(get_bit(i) == 1){
return -1;
}
}
return 1;
}
}