ZOJ 3488 Conic Section(数学啊 )

题目链接: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;
}
时间: 2024-12-06 06:21:20

ZOJ 3488 Conic Section(数学啊 )的相关文章

poj 1543 &amp; HDU 1334 &amp; ZOJ 1331 Perfect Cubes(数学 暴力大法好)

题目链接:http://poj.org/problem?id=1543 Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > 2 there exist no integers a, b, c > 1 such that a^n = b^n + c^n, has remained elusively unproven. (A recent proof is believ

ZOJ 3903 Ant(数学,推公示+乘法逆元)

Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's

zoj.3868.GCD Expectation(数学推导&gt;&gt;容斥原理)

GCD Expectation Time Limit: 4 Seconds                                     Memory Limit: 262144 KB Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has equal probability to be pick

ZOJ 3710 Friends(数学啊 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3710 Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends

ZOJ 2988 Conversions(数学啊)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1987 Conversion between the metric and English measurement systems is relatively simple. Often, it involves either multiplying or dividing by a constant. You must write a program that co

ZOJ - 3866 Cylinder Candy (数学,积分)

Cylinder Candy Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu Submit Status Description Edward the confectioner is making a new batch of chocolate covered candy. Each candy center is shaped as a cylinder with radius r mm an

ZOJ 2680 Clock(数学)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1680 There is an analog clock with two hands: an hour hand and a minute hand. The two hands form an angle. The angle is measured as the smallest angle between the two hands. The angle be

ZOJ 3483 Gaussian Prime(数学啊 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4280 In number theory, a Gaussian integer is a complex number whose real and imaginary part are both integers. The Gaussian integers, with ordinary addition and multiplication of complex

LaTeX数学模式&amp;上下标&amp;代码块

效果就是如上图所示了.学习了使用数学模式插入公式和使用上标和公式的编号.这里的目录没有展开,在编译一次目录会展开,代码块会被挤到下一页上面去. \documentclass[UTF8]{ctexart} \title{练习使用LaTeX的数学公式} \author{NianHao} \date{\today} %引入数学功能 \usepackage{amsmath} %引入代码块 \usepackage{listings} \usepackage{fontspec} \usepackage{xc