I don't think I understand the problem properly. Does the ship start at (0,0) or (0, b)? I don't see how it can start at (0,0) and travel on the line if when (0,0) is not a the line. Could someone clarify this for me?
Qualification Competitions - Task: IT
It starts traveling at x=0 and travels in +x direction.
Thats the only thing I know for sure. Since in both cases ( (0,0) & (0,b) ) x = 0. However, I'm not sure about the y term. The problem does state that it starts at (0,0) but then it contradicts itself by saying that it follows the path of the line. Am I missing something?
if (x>=0 && m*x+b==y) c++;
When you compare to doubles, or floates you can't compare then with (==), you have to use fabs. so it will be: if (x>=0 && fabs((m*x+b) - y) < 0.00001 ) c++;
When you compare to doubles, or floates you can't compare then with (==), you have to use fabs. so it will be: if (x>=0 && fabs((m*x+b) - y) < 0.00001 ) c++;
Ah thanks, I should be more careful with doubles.
@frank44:
Your solution is good, just use scanf & printf instead of cin & cout and you'll pass the time limit on the 9-th and 10-th test case. ;)
Your solution is good, just use scanf & printf instead of cin & cout and you'll pass the time limit on the 9-th and 10-th test case. ;)