Блог пользователя TranThuyLuc

Автор TranThuyLuc, 7 лет назад, По-английски

In many contest problems in Codeforces where the results require float point number, there is often something like this:

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

However, the normal way to check whether two float point numbers are equal is something like this:

const double EPS = 1e-9;

bool isEqual(double x, double y){
    return abs(x - y) < EPS;
}

Is the way Codeforces use more precise? Should I use this way for comparing float point numbers instead of the normal way?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится