zoukankan      html  css  js  c++  java
  • ZOJ 3488 Conic Section

    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 sectionequation
    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

    #include <iostream>
    #include<cstdio>
    using namespace std;
    double a,b,c,d,e,f;
    int t;
    int main()
    {
        scanf("%d",&t); //开始写成while(~scanf("%d",&t)),tle了
            for(;t>0;t--)
            {
                scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f); //题目没读清楚,题目说是实数,我用了%d,就wa了好几次
                if (a==c) printf("circle
    "); else //判断是什么形状取决于a和c的关系。
                if (a!=c && a*c>0) printf("ellipse
    "); else
                if (a==0 || c==0) printf("parabola
    "); else
                if (a*c<0) printf("hyperbola
    ");
            }
        return 0;
    }
  • 相关阅读:
    关于Python装饰器内层函数为什么要return目标函数的一些个人见解
    多项式拟合与线性回归
    numpy基本方法总结 --good
    numpy中的convolve的理解
    最容易理解的对卷积(convolution)的解释
    Python之numpy基本指令
    线性回归原理小结
    矩阵的导数与迹
    【MyBatis学习14】MyBatis和Spring整合
    【MyBatis学习13】MyBatis中的二级缓存
  • 原文地址:https://www.cnblogs.com/stepping/p/6386147.html
Copyright © 2011-2022 走看看