Pro.ID22759 TitleCutting the Cake Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22759 AC0 Submit0 Ratio- 时间&空间限制描述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 Sample Output 1 1.00000 0.00000 4.00000 Source 样例输入4 样例输出1 1.00000 0.00000 4.00000 作者 |