Problem Link : https://www.spoj.com/problems/CT/
My Approach
I have first counted all possible squares that can be formed within (0,0) and (x,y). The counting is done by same counting done in CNN neural network concept where we first take stride of 1 and find number of squares then stride of 2 and so on. Then i have multiplied the final total number of possible squares with 4 as each square can have 4 possible isosceles triangle. Then print the result.
My Doubt
Still i am getting wrong answer error. I have checked the test cases in codeforce (same problem are posted in spoj as well as in codeforce) and some test case answer seem to be incorrect (some answers are not divisible by 4). May be i have not understand the problem well.
Please help me to find my mistake or my solution fault.
Following is my solution code :
#include <bits/stdc++.h>
using namespace std;
int main()
{
unsigned int t, x, y;
unsigned long long ans;
cin >> t;
while (t) {
cin >> x >> y;
ans = 0;
for (int side=1; side<=min(x,y); side++)
ans += (x+1-side)*(y+1-side);
ans = ans * 4;
cout << ans << endl;
t--;
}
return 0;
}