Project Euler #224: Almost right-angled triangles II

  • + 0 comments

    This code is Timed out for all the test cases except the test case 0.can any one explain me where i did wrong?

    include

    include

    include

    include

    int main() { long long int n,q,a,b,c,d=0; scanf("%lld",&q); while(q--) { scanf("%lld",&n); for(a=1;a<=n;a++) { for(b=a;b<=n;b++) { for(c=a;c<=n;c++) { if( pow(a,2)+pow(b,2) == pow(c,2)-1 ) { if(a+b+c<=n) d++; //printf("%lld %lld %lld \n",a,b,c); } } } } printf("%lld\n",d); }

    return 0;
    

    }