HBC209142GeometryChallenge题解

惰性的成熟 算法基础篇 39 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
ZYB hasan acute intuition in mathematics, especially in geometry problems. The geometry problem looks like this: Please find the value of ∠CAMangle CAM∠CAM. Or looks like this

ZYB has an acute intuition in mathematics, especially in geometry problems. The geometry problem looks like this: Please find the value of ∠CAMangle CAM∠CAM. Or looks like this: If AC=x−3,BE=20,AB=16,CD=x+5{AC=x-3,BE=20,AB=16,CD=x+5}AC=x−3,BE=20,AB=16,CD=x+5. Please find the value of x. To parse the problem easier, the input will contain logic forms instead of the original problem text and diagram. The primitive logic forms are as follows: Number. Use decimal integers to represent numbers. Unknown number. x is the only unknown number.  Expression. An expression is either a Number or an expression in which x appears exactly once, combined with at most one addition/subtraction and at most one multiplication. The multiplication sign can be omitted. e.g. 233, 3x+5, x*2+3, x-2 are valid expressions, but 3x+5-3, x+2x, 5*3, 2y not. Point. Use single capital letters to represent points. Line. Use Line(Point, Point) to represent a line (actually it's a segment). e.g. Line(A, B) Angle. Use Angle(Point, Point, Point) to represent an angle. e.g. Angle(A,B,C) Circle. Use Circle(Point) to represent an circle with specific center. e.g. Circle(O) Length of Line. Use LengthOf(Line) to get the value of specific segment's length. e.g. LengthOf(Line(A, B)) Angle Measure. Use MeasureOf to get the value of specific angle's degree. e.g. MeasureOf(Angle(A,B,C)) Term.Term = Length of Line | Angle Meausre | Expression. Equal. Use Equals(Term, Term) to state that the values of these two terms are equal. e.g. Equals(LengthOf(A,B), 2), Equals(MeasureOf(angle(A, B, C)), 2x+10) Perpendicular. Use Perpendicular(Line, Line) to represent two perpendicular lines. e.g. Perpendicular(Line (A, C), Line(B, D)) Parallel. Use Parallel(line, line) to represent two parallel lines. It is guaranteed that the points are in order. e.g. Parallel(Line (A, C), Line(B, D)) PointLiesOnLine. Use PointLiesOnLine(Point, Line) to represent a point lying on a line. e.g. PointLiesOnLine(A, Line(B, C)) PointLiesOnCircle. Use PointLiesOnCircle(Point, Circle) to represent a point lying on a circle. e.g. PointLiesOnCircle(A, Circle(O)) Question. Use Find(Term) to ask the exact value of the given term. e.g. Find(x), Find(LengthOf(Line(A,B))) Note that all the conditions in the diagram and text will be translated into logic forms. You are now given a list of logic forms with exactly one question (Find phrase) and wants to find out the solution. Following theorems are enough for you to solve the problem: Flat Angle Theorem: If point C{C}C lies on the segment AB{AB}AB, then ∠ACB=180∘angle ACB = 180^{circ}∠ACB=180∘. Triangle Equality Theorem: In triangle ABC{ABC}ABC, if AB=AC{AB=AC}AB=AC, then ∠ACB=∠ABCangle ACB=angle ABC∠ACB=∠ABC, and vice versa. Triangle Sum Theorem: Three interior angles of any triangle add up to 180∘180^{circ}180∘. The Pythagorean Theorem: In right-angled triangle, if the lengths of the three sides are a,b,c{a, b, c}a,b,c , respectively (where c{c}c is the hypotenuse), then a2+b2=c2a^2+b^2=c^2a2+b2=c2 always holds. Note that you don't need to use it inversely. Congruent Triangles Theorem: Two triangles are congruent if they satisfy the following conditions: https://en.wikipedia.org/wiki/Congruence_(geometry)#Congruence_of_triangles. The corresponding lengths and angles are equal in congruent triangles. Similar Triangles Theorem: Two triangles are similar if they satisfy the following conditions: https://en.wikipedia.org/wiki/Similarity_(geometry)#Similar_triangles. The corresponding angles are same and the corresponding sides are proportional in similar triangles. Parallel Lines Theorem: If two lines are parallel, then the pair of corresponding angles is equal, the pair of alternate angles is equal, the pair of interior angles on the same side of transversal is supplementary. Diameter Theorem: All diameters of a circle have the same length. The center of the circle is also the midpoint for each diameter. Point-On-CircleTheorem: If AB{AB}AB is a diameter of circle O{O}O and another point C{C}C lies on circle O{O}O, then ∠ACB=90∘angle ACB=90^{circ}∠ACB=90∘. ZYB gives some tips to you: Logic forms can be nested.  It is guaranteed that there exists at least one good solution for each case. A good solution means: You can use the theorems above step by step to solve the problem; After each step, the new values you acquire are all valid expressions (Which also means that the numbers involved in expressions are always integers); The number of steps does not exceed 4{4}4. The given logic forms is sufficient. For example, if there are four points A,B,C,D{A,B,C,D}A,B,C,D lying on a segment, then four corresponding PointLiesOnLine phrases (A-B-C, A-B-D,A-C-D,B-C-D) will be listed. And if you are given the phrase Perpendicular(Line (A, C), Line(B, D)), the intersection of these two lines will be also given (i.e. PointLiesOnLine(E, Line(A, C)) and PointLiesOnLine(E, Line(B, D)) if the intersection is E). If AO,BO,CO{AO,BO,CO}AO,BO,CO are three different segments, it's difficult to detect which segment is in the middle. In this problem, you do not need to build a relation between ∠AOB,∠AOC,∠BOC{angle AOB, angle AOC, angle BOC}∠AOB,∠AOC,∠BOC except in this obvious case: If B{B}B lies on segment AC{AC}AC, then you may use ∠AOC=∠AOB+∠BOC{angle AOC=angle AOB+angle BOC}∠AOC=∠AOB+∠BOC to solve the problem. All data are derived from real-world problems, not constructed artificially. There are totally 20{20}20 problems. The samples (including 10{10}10 problems) are selected from them.

HBC209142GeometryChallenge题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC209142GeometryChallenge题解