#include "grader.h"
int HC(int n) {
int lower_, lower, upper, g, x;
while (1) {
if (n == 1)
return 1;
if (n == 2) {
Guess(1);
return Guess(2) < 0 ? 1 : 2;
}
if (n == 3) {
Guess(1);
if (Guess(2) < 0)
return 1;
if (Guess(3) < 0)
return 2;
return 3;
}
Guess(1);
g = Guess(n / 2);
if (g == 0)
return (1 + n / 2) / 2;
if (g > 0)
break;
n /= 4;
}
lower_ = (1 + n / 2) / 2 + 1;
lower = n / 2, upper = n;
while (lower < upper) {
int mid = (lower + 1 + upper) / 2;
g = Guess(mid);
if (g == 0)
return (lower + mid) / 2;
if (g > 0)
lower_ = (lower + mid) / 2 + 1, lower = mid;
else {
upper = (lower + mid - 1) / 2, lower = lower_, x = mid;
while (lower < upper) {
mid = (lower + upper) / 2;
if (mid * 2 - x <= 0 || mid * 2 - x > n) {
if (lower > 1)
Guess(lower - 1), x = lower - 1;
else
Guess(upper + 1), x = upper + 1;
}
g = Guess(mid * 2 - x);
if (g == 0)
return mid;
else if ((g > 0) == (x < mid * 2 - x))
lower = mid + 1;
else
upper = mid - 1;
x = mid * 2 - x;
}
return lower;
}
}
return n;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
1268 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1268 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
1272 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
611 ms |
8176 KB |
Output isn't correct - alpha = 0.000000000000 |