CT2 - Counting triangles 2
Consider a 2D integer grid with lower left corner at (0, 0) and upper right corner at (X, Y). We are interested in isosceles right triangles with all the 3 corners at the grid nodes (integer coordinates).
The input begins with the number T of test cases in a single line. In each of the next T lines there are two integers X, Y.
For each test case, on a single line, print the number of such triangles.
Input: 2 0 3 1 1 Output: 0 4
1 <= T <= 10^4 0 <= X <= 10^4 0 <= Y <= 10^4
Your challenge is to give in time the answer with the shortest code. This problem is CT with more challenging constraints. Source limit is 512B My poorly golfed Py3 code scored 158B in 0.87s (for two input files). (time updated 2017-02-11 ; compiler changes)
can u give some more test cases?
I've increase a little time limit for slower languages.