Description
The conic sections are the nondegenerate curves generated by the intersections of a plane with one or two nappes of a cone. For a plane perpendicular to the axis of the cone, a circle is produced. For a plane that is not perpendicular to the axis and that intersects only a single nappe, the curve produced is either an ellipse or a parabola. The curve produced by a plane intersecting both nappes is a hyperbola.
conic section | equation |
---|---|
circle | x2+y2=a2 |
ellipse | x2/a2+y2/b2=1 |
parabola | y2=4ax |
hyperbola | x2/a2-y2/b2=1 |
Input
There are multiple test cases. The first line of input is an integer T ≈ 10000 indicating the number of test cases.
Each test case consists of a line containing 6 real numbers a, b, c, d, e, f. The absolute value of any number never exceeds 10000. It's guaranteed thata2+c2>0,b=0, the conic section exists and it is non-degenerate.
Output
For each test case, output the type of conic section ax2+bxy+cy2+dx+ey+f=0. See sample for more details.
Sample Input
5 1 0 1 0 0 -1 1 0 2 0 0 -1 0 0 1 1 0 0 1 0 -1 0 0 1 2 0 2 4 4 0
Sample Output
circle ellipse parabola hyperbola circle
References
- Weisstein, Eric W. "Conic Section." From MathWorld--A Wolfram Web Resource.http://mathworld.wolfram.com/ConicSection.html
#include<stdio.h>
int main()
{
int m;
while(scanf("%d",&m)!=EOF)
{
while(m--)
{
double a,b,c,d,e,f;
scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);
if(a==c&&(d*d+e*e-4*a*f>0))
printf("circle\n");
else if(a*c<0&&((d*d/(4*a*a)) + (e*e/(4*c*c))-f))
printf("hyperbola\n");
else if((!a && d && c) || (!c && e && a))
printf("parabola\n");
else
printf("ellipse\n");
}
}
return 0;
}