22759_CuttingtheCake

2022-5-16 18:22| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506931495800-Problem List-采集的数据-后羿采集器.html

Pro.ID

22759

Title

Cutting the Cake

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22759

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    For each birthday of twins James and John, their mother bakes a special triangular birthday cake with a different shape each year. The sides of the cake are frosted with chocolate icing and the top is frosted with special pink icing. James and John both like both types of icing and insist that they get their equal share of each.

    Write a program to help James and John cut the cake so they each get an equal share. A triangle equalizer is a line through a triangle that simultaneously divides the perimeter and area of the triangle into two equal pieces. If the triangle is isosceles, the bisector of the angle between two equal sides is such a line (A and B below). In general, a triangle may have1, 2 or 3 such lines (2 requires special conditions not likely to be found in a random triangle).

    Write a program to compute the equation of one such dividing line (it does not matter which one) for a non-degenerate input triangle. You should use double-precision calculations for intermediate values.

    输入

    The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing a single decimal integer and 6 floating point numbers. The integer is the data set number (starting at 1). The floating-point numbers are the coordinates of the vertices of the input triangle: x0, y0, x1, y1, x2, y2.

    输出

    Description

    For each birthday of twins James and John, their mother bakes a special triangular birthday cake with a different shape each year. The sides of the cake are frosted with chocolate icing and the top is frosted with special pink icing. James and John both like both types of icing and insist that they get their equal share of each.

    Write a program to help James and John cut the cake so they each get an equal share. A triangle equalizer is a line through a triangle that simultaneously divides the perimeter and area of the triangle into two equal pieces. If the triangle is isosceles, the bisector of the angle between two equal sides is such a line (A and B below). In general, a triangle may have1, 2 or 3 such lines (2 requires special conditions not likely to be found in a random triangle).

    Write a program to compute the equation of one such dividing line (it does not matter which one) for a non-degenerate input triangle. You should use double-precision calculations for intermediate values.

    Input

    The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing a single decimal integer and 6 floating point numbers. The integer is the data set number (starting at 1). The floating-point numbers are the coordinates of the vertices of the input triangle: x0, y0, x1, y1, x2, y2.

    Output

    For each data set, there is a single line of output. The line contains a decimal integer giving the data set number followed by a single space, followed by 3 space-separated floating-point numbers to 5 decimal places. The 3 floating-point values are the coefficients (A, B and C) of the equation of the equalizer line:

    A * x + B * y = C

    where A*A + B*B = 1.0 and A ≥ 0.

    Sample Input

    4
    1 0 0 4 10 8 0
    2 0 0 10 8 8 0
    3 0 0 -8 4.5 5 0
    4 0 0 -5 4.6 5 0

    Sample Output

    1 1.00000 0.00000 4.00000
    2 0.99347 -0.11408 5.98771
    3 0.45018 0.89294 0.81417
    4 0.66369 0.74801 1.01564

    Source

    样例输入

    4
    1 0 0 4 10 8 0
    2 0 0 10 8 8 0
    3 0 0 -8 4.5 5 0
    4 0 0 -5 4.6 5 0

    样例输出

    1 1.00000 0.00000 4.00000
    2 0.99347 -0.11408 5.98771
    3 0.45018 0.89294 0.81417
    4 0.66369 0.74801 1.01564

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部