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 :)
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
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 :)
Название |
---|
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.