IntGrid
You are given a triangle with its endpoints (0, 0), (n, m), (n, 0). You have to find the number of integer coordinates (a, b) that are inside the given triangle. If a coordinate is on the triangle edge (side) then we consider that it is inside the triangle.
InputFrom the first line of the standard input read two integers n and m (0 <= n, m <= 1 000 000 000).
30% test cases will have (0 <= n, m <= 1 000).
60% test cases will have (0 <= n, m <= 1 000 000).
30% test cases will have (0 <= n, m <= 1 000).
60% test cases will have (0 <= n, m <= 1 000 000).
OutputTo the standard Output write one integer representing the number of integer points (points with integer coordinates) that are inside the given triangle.
Input:
Output:
Objašnjenje:
The points with integer coordinates inside the triangle are:
(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (2, 1),
(3, 1), (4, 1), (5, 1), (4, 2), (5, 2), (5, 3), .
5 3Output:
13Objašnjenje:
The points with integer coordinates inside the triangle are:
(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (2, 1),
(3, 1), (4, 1), (5, 1), (4, 2), (5, 2), (5, 3), .
Input:
Output:
17 21Output:
199Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.