Simple Billiards
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

A w×h rectangular billiard table is placed on the two-dimensional xOy plane. The lower left corner of the table is located at (0,0), the upper right corner is located at (w,h), and there is a pocket at each corner.
Now a ball initially positioned at (x,y), which is inside the table, is hit in the direction of Ox rotated counterclockwise by r degrees. Whenever the ball hits the side of the table not at a corner, it is reflected in the mirror direction, and it continues to travel on the table until the ball reaches a corner and drops into a pocket. You need to determine if the ball will eventually drop into a pocket.
To simplify the problem, the ball and the pockets are treated as a point. That is, the ball can drop into a pocket if and only the ball is positioned exactly on some pocket at some time.

二维 xOy 平面内放置着一张 w×h 的长方形台球桌。球桌左下角的坐标是 (0,0)、右上角的坐标是 (w,h),并且每个角都开有一个球袋。
现在有一颗初始位于球桌内部 (x,y) 位置的球沿 Ox 逆时针旋转 r 度的方向被击出。当球碰到球桌边缘(但不是球桌的角)时,会遵循反射定律反弹回去,然后在球桌上继续前进直到碰到球桌的某个角并落入球袋。你需要判断这颗球最终是否会落入某个球袋中。
为了简化问题,球和每个球袋都会被看作是一个点,球能落袋当且仅当某时刻球的位置恰好在某个球袋上。

输入描述:

The first line contains two integers w (2 ≤ w ≤ 50) and h (2 ≤ h ≤ 50), indicating the size of the billiard table.
The second line contains two integers x (0 < x < w) and y (0 < y < h), indicating the initial position of the ball.
The third line contains one integer r (0 ≤ r < 360), which means that the ball is hit in the direction of Ox rotated counterclockwise by r degrees.

第一行是两个整数 w (2 ≤ w ≤ 50) 和 h (2 ≤ h ≤ 50),表示台球桌的规格。
第二行是两个整数 x (0 < x < w) 和 y (0 < y < h),表示球的初始位置。
第三行是一个整数 r (0 ≤ r < 360),表示球会沿 Ox 逆时针旋转 r 度的方向被击出。

输出描述:

If the ball will eventually drop into a pocket, output "Yes" (without quotes), otherwise output "No" (without quotes).

如果球最终会落袋,输出 "Yes"(不含引号),否则输出 "No"(不含引号)。
示例1

输入

复制
4 4
2 2
45

输出

复制
Yes
示例2

输入

复制
4 4
1 3
45

输出

复制
No
示例3

输入

复制
4 4
2 2
30

输出

复制
No