← Back to topics
Topic

IT

a
adnanbobo
Am i missing something here? The task looks really simple, still I get wrong result in the tests. Can someone tell me what the trick is, or what am I doing wrong?

#include <iostream>

using namespace std;

int main()
{
double k,n,x1,y1;
scanf("%lf %lf",&k,&n);
int N,rjes;
rjes=0;
scanf("%d",&N);

for (int i=0;i<N;i++)
{
scanf("%lf %lf",&x1,&y1);
if ((x1>=0.0) && (y1==x1*k+n))rjes++;
}
printf("%d\n",rjes);
system("pause");
return 0;
}
g
gates
compare doubles with:

 if( abs( x-y ) < EPS ) 

instead of:
 if( x == y ) 


where EPS is some very small value.
A
Al3kSaNdaR
In this task 0.001 is enough.
a
adnanbobo
Thank you, it's ok now