Submit | All submissions | Best solutions | Back to list |
GARD - Garden Hose |
Our garden is a square containing plants in n rows and n columns, a total of n*n plants. The distance between plants within a row is rowDist and between plants within a column is colDist. I want to water the garden without getting my shoes muddy. That requires that I stand outside the garden, never closer than where the next row or column of the garden would be if it were enlarged. The hose can water plants that are hoseDist or less away from where I am standing. (Of course, I can move around and water from various locations.) Given n, rowDist, colDist, and hoseDist as inputs, you must find and print the number of plants that cannot be watered.
Input Specification
The input will contain several test cases, each test cases will consit on a line containing n , rowDist, colDist and hoseDist,1<=n,rowDist,colDist<=50 and 1<=hoseDist<=10000.
Output Specification
Print one line per test case with the answer, follow the format below Input Example
3 2 1 2
3 2 1 1
4 50 2 2
4 50 2 4
4 3 2 3
Output Example
0
3
8
0
4
Added by: | Fabio Avellaneda |
Date: | 2013-02-02 |
Time limit: | 3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP JAVA |
Public source code since: | 2013-02-21 06:00:00 |