zoukankan      html  css  js  c++  java
  • Conic Section(圆锥曲线基础)

    Conic Section

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    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 a, b, c, d, e, f. The absolute value of any number never exceeds 10000. It's guaranteed that a2+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

    首先,题目已经提示了b=0,就是不需考虑旋转,大大降低了题目难度。

    其次,题目说明了曲线不会退化。

    另外需要注意的是,曲线方程不一定如题中所示的标准形式,需要考虑平移的形式。如圆:(x-a)^2+(y-b)^2=c^2。

     1 #include <iostream>
     2 #include <string>
     3 #include <cstdio>
     4 #include <cmath>
     5 #include <cstring>
     6 #include <algorithm>
     7 #include <map>
     8 #include <vector>
     9 #include <set>
    10 #include <queue>
    11 #include <stack>
    12 #define LL long long
    13 #define MAXI 2147483647
    14 #define MAXL 9223372036854775807
    15 #define eps (1e-8)
    16 #define dg(i) cout << "*" << i << endl;
    17   
    18 using namespace std;
    19   
    20 int main()
    21 {
    22     double a, b, c ,d ,e ,f;
    23     int t;
    24     cin >> t;
    25     while(t--)
    26     {
    27         cin >> a >> b >> c >> d >> e >> f;
    28         if(a && a == c && d*d + e*e - 4*a*f > 0) puts("circle");
    29         else if(a*c < 0 && (d*d/(4*a*a)) + (e*e/(4*c*c)) - f) puts("hyperbola");
    30         else if((!a && d && c) || (!c && e && a)) puts("parabola");
    31         else puts("ellipse");
    32     }
    33     return 0;
    34 }
  • 相关阅读:
    io系列之常用流一
    C++ 函数参数的默认值
    C++ 函数匹配和作用域声明
    c++ vector 迭代器 demo
    C++ 函数重载和匹配
    C++函数重载和const
    C++函数重载
    iOS开源项目
    Linux系统/网络 笔记
    IO五种模式
  • 原文地址:https://www.cnblogs.com/cszlg/p/2932432.html
Copyright © 2011-2022 走看看