I have tested it against small test cases and all boundary cases but am still not able to find what the error is. Can somebody please guide/help me. Here is the link to my submission. Thanks in advance :)
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
I have tested it against small test cases and all boundary cases but am still not able to find what the error is. Can somebody please guide/help me. Here is the link to my submission. Thanks in advance :)
Name |
---|
i guess it's precision problem..avoid using floats may be..
But am not using it to calculate anything, just using it to calculate slope, which will be same even if my numerator and denominator are different(as in they still have same gcd to give same slope). I even used double. Its still wrong answer for test case 4.
you can't compare double like this:
see this link
Never trust in doubles :v , i mean that when you are using float , double , long double you can't compare with == , < , > as usual integer comparation , this issue happens because you are using operation a real number(can have infinite decimal digits — decimal periodic) in a double and you will lose precision because the number is truncated in some decimals , it is convenient to compare doubles with
abs(x - y) < = EPS where EPS = 1e - 8
its enough for almost of problems or you need to change of focus and use only integers.
In calculating slope, one way is to keep it in p/q form where p and q are coprimes.