Problem Description: A double-square number is an integer M which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 3^2 + 1^2 . Your task in this problem is, given M , determine the number of ways in which it can be written as the sum of two squares. For example, 10 can only be written as 3^2 + 1^2 (we don't count 1^2 + 3^2 as being different). On the other hand, 25 can be written as 5^2 + 0^2 or as 4^2 + 3^2 . Constraints: 0 ≤ M ≤ 2147483647 1 ≤ N ≤ 100
C Program


#include <stdio.h>

#include <math.h>

int main()

{

    int n,i;

    long long M;

    scanf("%d",&n);

    for(i = 1;i<= n;i++)

    {

        scanf("%lld",&M);

        long long a,b;

        int count=0;

        long long limit = sqrt(M/2);

        for(a=0;a<=limit;a++)

        {

            long long rem = M - a*a;

            b = sqrt(rem);

            if(b*b == rem)

                count++;

        }

        printf("%d\n",count);

    }

    return 0;

}