码迷,mamicode.com
首页 > 其他好文 > 详细

ZOJ 3488 Conic Section(数学啊 )

时间:2015-04-18 20:41:42      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:数学   zoj   

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4311


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 abcdef. The absolute value of any number never exceeds 10000. It‘s guaranteed that a2+c2>0b=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


Author: WU, Zejun
Contest: The 8th Zhejiang Provincial Collegiate Programming Contest

PS:

不要想的太复杂!

代码如下:

#include<cstdio>
int main()
{
    int t,n;
    double a,b,c,d,e,f;
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);
            if( a == c)
                printf("circle\n");
            else if( a == 0 || c == 0 )
                printf("parabola\n");
            else if( a * c < 0 )//异号
                printf("hyperbola\n");
            //else if(a!=c && a*c > 0)
            else
                printf("ellipse\n");
        }
    }
    return 0;
}


ZOJ 3488 Conic Section(数学啊 )

标签:数学   zoj   

原文地址:http://blog.csdn.net/u012860063/article/details/45115605

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!