Under construction

Still being built. Things may change

Fitting on the Bed

Time limit1sMemory limit1024 MB

Summary
Given the bed size, Anya's head position, and her angle, decide whether a segment of length H from her head stays inside the bed.
Level

Medium4 of 10

Topics
Geometry, Math, Implementation
Solved
No attempts yet

Problem

Anya is Arup's daughter. She does not sleep in a bed the usual way. She can put her head anywhere, and she can lie in any direction. For this problem, Anya is very thin (she is at the fifth percentile in weight), so she is modeled as a line segment with her head at one end. The bed is a rectangle whose bottom left corner is (0, 0), whose top left corner is (0, L), and whose top right corner is (W, L). L is the length of the bed and W is its width.

In the left diagram below, Anya's head is near the top left corner and she lies completely sideways, off the bed. This is the first case. In the right diagram, her head starts a little lower than in the first diagram, but she lies on a diagonal, and that lets her fit on the bed.

Input

The first line has three positive integers: L (L ≤ 500), the length of the bed in centimeters, W (W ≤ 500), the width of the bed in centimeters, and H (H ≤ 200), Anya's height in centimeters.

The second line has three non-negative integers: x (x ≤ W), the distance in centimeters from the left side of the bed to Anya's head, y (y ≤ L), the distance in centimeters from the bottom of the bed to her head, and a (a ≤ 359), the angle in degrees that her body faces, measured from her head.

Output

Print YES if Anya fits completely on the bed, and NO otherwise. In every case where she does not fit, at least 1% of her body is off the bed. If part or all of her body touches an edge of the bed but none of it extends past the edge, she counts as on the bed.

Hint

In the first case, Anya's head is 40 cm from the left end of the bed near the top, and her body points fully to the right. Only 110 cm lies to the right of her head, and she is 115 cm tall, so 5 cm of her is off the bed.

In the second case, her head is 40 cm lower than in the first case. She lies on a diagonal in the direction a clock's hour hand points at 4:30. In this position, there are 110 cm to the right and 150 cm downward, so she fits on the bed.

Examples2

  1. Example 1

    Input
    200 150 115
    40 190 0
    
    Expected output
    NO
    
  2. Example 2

    Input
    200 150 115
    40 150 315
    
    Expected output
    YES