#include "cmp.h"
void remember(int n) {
int target = 2048;
int cnt = 1;
while (cnt <= 12) {
if (target < n) {
bit_set(target * 2 - 1);
bit_set(target * 2);
target += (target << cnt);
}
else if (target > n) {
bit_set(target * 2 - 1);
target -= (target << cnt);
}
else {
bit_set(target * 2 - 1);
break;
}
cnt++;
}
}
int compare(int b) {
int target = 2048;
int cnt = 1;
while (cnt <= 12) {
if (bit_get(target * 2 - 1)) {
if (bit_get(target * 2))
target += (target << cnt);
else
target -= (target << cnt);
}
else
break;
cnt++;
}
if (target > b)
return -1;
else if (target < b)
return 1;
else
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
ZERO POINTS: bit_set with addr out of range -4097 |