列表

详情


NC209142. GeometryChallenge

描述

ZYB has an acute intuition in mathematics, especially in geometry problems.

The geometry problem looks like this: Please find the value of $\angle CAM$.


Or looks like this: If . 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 numberx 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  lies on the segment , then .
  • Triangle Equality Theorem: In triangle , if , then , and vice versa.
  • Triangle Sum Theorem: Three interior angles of any triangle add up to .
  • The Pythagorean Theorem: In right-angled triangle, if the lengths of the three sides are  , respectively (where  is the hypotenuse), then  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-CircleTheoremIf  is a diameter of circle  and another point  lies on circle , then .
ZYB gives some tips to you:
  1. Logic forms can be nested. 
  2. 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 .
  3. The given logic forms is sufficient. For example, if there are four points  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).
  4. If  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  except in this obvious case: If  lies on segment , then you may use  to solve the problem.
  5. All data are derived from real-world problems, not constructed artificially.
  6. There are totally  problems. The samples (including  problems) are selected from them.

输入描述

The input contains multiple cases. The first line of the input contains a single integer , the number of cases.
For each case, the first line contains a integer , indicating the number of logic forms. The second line contains several capital letters seperated by space, indicating all the points related to this problem. The third line contains several strings of uppercase letters of length 2, indicating all the lines(segments) related to this problem. In the next  lines, there is a string  in each line, indicating the -th logic form. It is guaranteed that the last logic form starts with "Find".

输出描述

For each case, output an integer indicating the answer. The unknown number shouldn't be involved in.

示例1

输入:

5
11
N M B C T A D
MA MB MT MD AB AC BC TC TN CN
Equals(MeasureOf(Angle(M, T, N)), 28)
PointLiesOnLine(B, Line(A, C))
PointLiesOnLine(D, Line(T, N))
PointLiesOnCircle(N, Circle(M))
PointLiesOnCircle(C, Circle(M))
PointLiesOnCircle(T, Circle(M))
PointLiesOnCircle(A, Circle(M))
Perpendicular(Line(A, B), Line(M, B))
Perpendicular(Line(D, M), Line(T, D))
Equals(LengthOf(Line(B, M)), LengthOf(Line(D, M)))
Find(MeasureOf(Angle(C, A, M)))
8
A B C D E
AC AD AB AE BC BE CD DE
Equals(LengthOf(Line(A, C)), x-3)
Equals(LengthOf(Line(A, B)), 16)
Equals(LengthOf(Line(C, D)), x+5)
Equals(LengthOf(Line(B, E)), 20)
PointLiesOnLine(C, Line(A, D))
PointLiesOnLine(B, Line(A, E))
Parallel(Line(B, C), Line(E, D))
Find(x)
12
A B C D F
CB CD CA CF BD BA BF DA DF AF
Equals(MeasureOf(Angle(F, A, D)), 20)
Equals(LengthOf(Line(D, A)), 9)
Equals(MeasureOf(Angle(F, A, B)), 32)
Equals(LengthOf(Line(B, A)), 6)
Equals(MeasureOf(Angle(A, D, B)), 40)
PointLiesOnLine(F, Line(C, A))
PointLiesOnLine(F, Line(B, D))
Parallel(Line(A, D), Line(B, C))
Equals(LengthOf(Line(A, D)), LengthOf(Line(B, C)))
Parallel(Line(A, B), Line(D, C))
Equals(LengthOf(Line(A, B)), LengthOf(Line(D, C)))
Find(MeasureOf(Angle(D, B, A)))
5
A B C
AB BC AC
Equals(LengthOf(Line(A, B)), 2x-7)
Equals(LengthOf(Line(B, C)), 4x-21)
Equals(LengthOf(Line(A, C)), x-3)
Equals(LengthOf(Line(A, B)), LengthOf(Line(B, C)))
Find(LengthOf(Line(A, C)))
5
A B C
AB AC BC
Equals(LengthOf(Line(A, C)), 3)
Equals(LengthOf(Line(A, B)), 5)
Equals(LengthOf(Line(B, C)), x)
Perpendicular(Line(A, C), Line(B, C))
Find(x)

输出:

28
35
88
4
4

示例2

输入:

5
7
A C B D E
AB AC AE AD BE BC DE CD
Equals(LengthOf(Line(A, C)), 16)
Equals(LengthOf(Line(E, D)), 5)
Equals(LengthOf(Line(A, B)), 12)
PointLiesOnLine(B, Line(A, C))
Parallel(Line(C, D), Line(B, E))
PointLiesOnLine(E, Line(A, D))
Find(LengthOf(Line(A, E)))
12
A B C D F
CB CD CA CF BD BA BF DA DF AF
Equals(MeasureOf(Angle(F, A, D)), 20)
Equals(LengthOf(Line(D, A)), 9)
Equals(MeasureOf(Angle(F, A, B)), 32)
Equals(LengthOf(Line(B, A)), 6)
Equals(MeasureOf(Angle(D, B, C)), 40)
PointLiesOnLine(F, Line(C, A))
PointLiesOnLine(F, Line(B, D))
Parallel(Line(A, D), Line(B, C))
Equals(LengthOf(Line(A, D)), LengthOf(Line(B, C)))
Parallel(Line(A, B), Line(D, C))
Equals(LengthOf(Line(A, B)), LengthOf(Line(D, C)))
Find(MeasureOf(Angle(A, D, C)))
12
A B C D E F G
GC GD GB GF GA GE CE BF BA FA
Equals(MeasureOf(Angle(A, G, C)), 60)
PointLiesOnLine(F, Line(G, A))
PointLiesOnLine(G, Line(C, E))
PointLiesOnLine(G, Line(B, F))
PointLiesOnLine(G, Line(B, A))
PointLiesOnLine(F, Line(B, A))
PointLiesOnCircle(C, Circle(G))
PointLiesOnCircle(B, Circle(G))
PointLiesOnCircle(A, Circle(G))
PointLiesOnCircle(E, Circle(G))
Perpendicular(Line(G, F), Line(G, D))
Find(MeasureOf(Angle(B, G, E)))
3
A B C
AB AC BC
Equals(MeasureOf(Angle(A, B, C)), 40)
Equals(MeasureOf(Angle(C, A, B)), 25)
Find(MeasureOf(Angle(B, C, A)))
6
D A B K G
KG GD DA KA AB KB
Equals(MeasureOf(Angle(B, A, D)), 3x-70)
Equals(MeasureOf(Angle(K, G, D)), 120)
Equals(MeasureOf(Angle(G, D, A)), x)
Parallel(Line(K, G), Line(A, D))
PointLiesOnLine(A, Line(K, B))
Find(x)

输出:

15
128
60
115
60

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

上一题