0115. Components of Connectivity

Имя входного файла: connect.in
Имя выходного файла: connect.out
Ограничение по времени: 2 s
Ограничение по памяти: 64 megabytes

Your task is to find the number of components of connectivity of a real algebraic curve f(x, y)=0.

Input file

The total degree of the polynomial f(x, y) will not exceed 6, and all coefficients are integer numbers not exceeding 104 by their absolute values. The exact representation of polynomials is given by the following BNF:

Different tokens of input (with the exception of digits forming a <number>) are separated by any number of space and/or newline characters.

Output file

Output the number of components.

Examples:

connect.inconnect.out
X^2 + Y^2 - 11
X^2 - Y^2 - 12
Y^2 - X^3 - X^221


Источник: Petrozavodsk Summer 2003. Primary Contest, Sunday, August 24
Автор: Andrew Lopatin, Nick Durov

Обсудить       Отправить решение



Версия для печати