0115. Components of Connectivity
Input file name: | connect.in |
Output file name: | connect.out |
Time limit: | 2 s |
Memory limit: | 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.in | connect.out |
---|---|
X^2 + Y^2 - 1 | 1 |
X^2 - Y^2 - 1 | 2 |
Y^2 - X^3 - X^22 | 1 |
Source: Petrozavodsk Summer 2003. Primary Contest, Sunday, August 24
Author: Andrew Lopatin, Nick Durov
Discuss Submit a solution