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 | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 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.