Archimedes
Time limit1sMemory limit1024 MB
Given the spiral constant b and a target point, find the point on the spiral r = b * phi where the avatar must leave along its tangent to hit the target.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Binary search
- Solved
- No attempts yet
Problem

Archimedes's Spiral,
Archimedes is a new 2D video game with very simple rules. The player presses start, and the avatar begins moving along an Archimedean spiral from the origin. When the player presses a button, the avatar detaches from the spiral and keeps moving in the direction it is heading at that moment. The goal is to hit a target. After the avatar detaches, its path must not intersect any part of the spiral.
To study this game, write a program that takes the angular velocity of the spiral and computes the point where the player must press the button to release the avatar and hit the target.
An Archimedean spiral is traced by a point moving at constant speed along a line that rotates at constant angular velocity around the origin. In polar coordinates , the spiral is . Here is the distance from the origin, and is the angle between the point, the origin, and the unit vector . The constant sets the distance between successive rings of the spiral.
Input
The input is a single line with three real numbers , , and . Here is the parameter of the spiral , and is the target.
The constraints are and . It is guaranteed that , so the avatar stays on the spiral for at least one full 360 degree turn. The distance from to the closest point on the spiral is greater than . The value has up to 12 significant digits, and and have up to 3 digits after the decimal point.
Output
Print the and coordinates of the point on the spiral where the avatar leaves the spiral. After leaving, the avatar keeps moving in the same direction and hits the target without intersecting the spiral.
An answer is correct if the absolute or relative error of both and is at most .