Олимпиадный тренинг

Задача 45226. Turtle-2-10


Задача

Темы: ЕГЭ
The performer Turtle acts on a plane with a Cartesian coordinate system. At the initial moment, the Turtle is at the origin of coordinates, its head is directed along the positive direction of the y-axis, the tail is lowered. With the tail lowered, the Turtle leaves a trail in the form of a line on the field. At each specific moment, the position of the performer and the direction of his movement are known.
The performer has commands: Forward n and Back n (where n – is an integer), causing the Turtle to move by n units in the appropriate direction,  Right m and Left m (where m – is an integer) causing the direction to change to m degrees clockwise  or counterclockwise respectively.

Recording
Repeat k [Command1 Command2 … CommandS]
means that the sequence of S commands will be repeated k times.

Determine how many points with integer positive coordinates will be inside the area bounded by the line defined by the following algorithm (without taking into account points on the line):
Repeat 21 [Forward 4 Right 36]