To solve this problem, we need to find the length of a chord in a circle given the radius of the circle, the distance from the center to the chord, and the angle subtended by the chord at the center.
Approach
The key insight here is that the length of a chord can be calculated using the radius (r) and the distance from the center to the chord (d). The formula for the chord length is derived from the Pythagorean theorem:
- Draw a perpendicular from the center to the chord, which bisects the chord. This forms a right triangle with the radius as the hypotenuse, the distance from the center to the chord as one leg, and half the chord length as the other leg.
- The length of half the chord is √(r² - d²), so the full chord length is 2 * √(r² - d²).
Solution Code
import math
r, d, a = map(int, input().split())
chord_length = 2 * math.sqrt(r**2 - d**2)
print("{0:.2f}".format(chord_length))
Explanation
- Reading Input: The input consists of three integers: radius (r), distance from center to chord (d), and angle (a). Although the angle is given, we don't need it for this approach since we use the radius and distance directly.
- Calculation: Using the formula for chord length, we compute the length using the radius and distance.
- Output: The result is formatted to two decimal places to ensure the correct precision as required.
This approach efficiently computes the chord length with minimal computational overhead and ensures accuracy up to two decimal places. The use of the Pythagorean theorem makes the solution straightforward and easy to understand.


作者声明:本文包含人工智能生成内容。