Count the number of distinct squares you can draw using only integer co-ordinates for its 4 corners with
the following restrictions.
• The edges should be parallel to the x and y axes
• The x and y co-ordinate of each corner should be within the range 0 to 2*n (range includes 0 and 2*n).
• None of the corners should lie in the central 2*k by 2*k square. It means both x and y co-ordinates of the corners should not lie in the range (n-k) to (n+k) (range inclusive of both ends) at the same time.
Two squares are distinct if and only if at least one of its corners is different.
Note that the edges can go through the central forbidden square. The only condition is that the corners itself should not lie in the central forbidden square.
The first line contains one integer t, the number of testcases. (1 <= t <= 100)
This will be followed by t test cases. Each case is specified in a separate line containing two space separated integers n and k.
For each testcase print the number of distinct squares you can draw under the given constraints.
2 2 1 3 1
1 30
Migrated from old NTUJ.
ACM-ICPC Asia-Amritapuri Site 2009
No. | Testdata Range | Score |
---|