Practice - 1 "Sofia the first". Linear Algorithms




Task
Time limit: 1000 ms,
Memory limit: 256 Mb

King Roland wants to become a baker and lead a simple lifestyle.
The royal kitchen is covered with a kitchen apron, which is divided into squares with side A see. Roland wants to hang a picture of his family on the apron. He knows the point at which the lower left corner of the painting is in contact, as well as the width and height of the painting itself. And then he wanted to know the number of squares that would be partially or completely covered by the picture.

Input:
The first line contains the number A - the side of one square of the kitchen apron.
The second and third lines - the numbers X and Y - are the coordinates of the lower left corner of the picture.
The fourth and fifth lines - the numbers W and H - the width and height of the picture.
The axis OX is directed to the right, the axis OY is directed up.
The lower left corner of one of the squares of the kitchen apron is at the origin. All numbers are integers not exceeding 2 × 109, numbers A, W, H are positive, numbers X and Y are positive or equal to 0.
Output:
Print one number - the number of tiles completely or partially covered by the picture.
A square is considered a closed picture if the intersection of the picture and the square has a non-zero area, that is, touching the picture and the square is not considered overlapping.
 

Example

Input Output  

1

10 

15 

35 

20

12

Side of the square (side of the cell in the figure) A = 10.
The lower left corner of the picture has coordinates (15, 5), the picture has a width of 35 cm and a height of 20 cm.
The painting completely or partially covers 12 squares


Prohibited statements:if;for;while;do;max;min;ceil

Auto CHOOSE THE PROGRAMMING NECESSARY LANGUAGE!
Attach the program source file:
or enter the source code in the language:

Rules for designing programs and a list of errors during automatic task verification
           

Results: