You are viewing a single comment's thread. Return to all 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?
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;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #224: Almost right-angled triangles II
You are viewing a single comment's thread. Return to all 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); }
}