#P1426. Fish and Hunter: Will the Fish be Caught?
Fish and Hunter: Will the Fish be Caught?
Fish and Hunter: Will the Fish be Caught?
A fish starts swimming from point A along a straight line to the right. In the first second, it swims meters. From the second second onward, in each second it swims only of the distance it swam in the previous second. That is, if the distance in the first second is , then for every subsequent second the distance is [ d_i = 0.98\times d_{i-1}, ] and the cumulative distance after seconds is [ T_n = 7\cdot\frac{1-0.98^n}{1-0.98} = 350\left(1-0.98^n\right). ]
A devious hunter has installed a hidden detector at a point meters to the right of A. The detector monitors a region extending meters to its left and right, i.e. the detection zone is the interval [ [s-x,; s+x]. ] If the fish enters this range at any moment during a second, the detector will send a signal at the end of that second. One second after the signal is sent the hunter will attempt to catch the fish if it is still within the detector zone. In other words, once the fish enters the detector zone, if it cannot completely exit the zone within the next one second, it will be caught.
Given the values of and , determine whether the fish is in danger. Output a single character: output y
if the fish is in danger, and n
if it is safe.
Note: The fish moves continuously with uniform speed in each second. The moment it crosses into the detector zone (if it does) during a second is considered as triggering the detector at the end of that second. Then the fish gets exactly one more second to exit the detector zone before the hunter catches it.
inputFormat
The input consists of two space-separated numbers: and , where (in meters) is the position of the detector and (in meters) is the half-length of the detector's range.
outputFormat
Output a single character: y
if the fish is in danger, or n
if the fish is safe.
sample
100 5
y