#include <iostream>
#include <assert.h>
#include "grader.h"
using namespace std;
#define MAX_N 1000000
#define min(a, b) (((a) > (b))?(b):(a))
#define max(a, b) (((a) > (b))?(a):(b))
//*
int HC(int n)
{
int min = 1, max = n, previous_guess = 1, guess = 0, hot_cool;
Guess(1);
while (min < max)
{
//assert(min > 0 && min <= n);
//assert(max > 0 && max <= n);
guess = min + max - previous_guess;
guess = min(guess, n);
guess = max(guess, 1);
assert( guess >= 1 && guess <= n);
hot_cool = Guess(guess);
if (hot_cool == 0)
{
//assert((previous_guess + guess + 1) & 1);
return ((previous_guess + guess) >> 1);
}
int mid = (previous_guess + guess) / 2;
int mod = (previous_guess + guess) & 1;
if (hot_cool > 0)
{
if (guess > previous_guess)
min = mid + mod;
else
max = mid;
}
else
{
//assert(hot_cool < 0);
if (guess > previous_guess)
max = mid;
else
min = mid + mod;
}
previous_guess = guess;
}
return min;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
1272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
1272 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
808 ms |
8184 KB |
Output isn't correct - alpha = 0.000000000000 |