What the heck Leetcode?

I am doing the Count Square Sum Triples problem. I am not getting used to using class a method to submit, but I tried, as I've already registered for the contest. Here's my code in C++

class Solution {
public:
    int countTriples(int n) {
        ios::sync_with_stdio(0);
    cin.tie(0);
        int ans=0;
    cin>>n;
    for (int i=1;i<n-1;i++)
        for (int j=i+1;j<n;j++)
            if (i*i+j*j<=n*n)
        {
            double c=sqrt(i*i+j*j);
            int chck=sqrt(i*i+j*j);
            if (c==chck)
                ans+=2;
        }
    return ans;
    }
};

I tried the sample test case and it works (In this case, input is 5 and output is 2). BUT, when I submitted it, the compiler says my output was actually 4!! Why the heck does this happen??

Comments (1)