### AFN's blog

By AFN, history, 5 years ago, Hi everyone!

I'm really facing problems in when to use modular inverse. I know that you should use it when calculating the following

(a / b)%p = (a * bp - 2)%p [Only when p is prime]

I know there is a case when subtracting, but I don't know how you do it exactly, can you tell me how? And are there any other cases? By AFN, history, 5 years ago, Hello Codeforces community.

It's been a long time since I last solved a problem on CF, so I decided I'd solve some Div. 2 As and Bs before I start solving Cs.

Anyway, I was solving problem 29B - Traffic Lights, that's when I saw WA on test 12 after submitting it. What's weird isn't the WA in particular, it's the reason; "Can't find file C:\Contesters\Work\invoker-prod\work\codeforces2\b00a58c7139058a693e243e272a449d7\check-aa5f5d80dec38086488721f39ffc5878\run\output.fd0138e687.txt.".

27794085

As CF doesn't let you send the same code twice, I just added a small comment in my code and re-sent it. Surprise, AC.

You can find my submission with the same code but with an added comment below

27794123

Isn't this considered a fatal problem? Or is it just because it is an old problem so there are issues?

Imagine having a wrong answer verdict like this in a rated contest!  wa, 29b,
By AFN, history, 5 years ago, To all those who participated in round 405:

For example, my rating has become 1593 after the last contest but is still shown 1621. Is everyone experiencing this problem? By AFN, history, 6 years ago, Hey guys I wanted to share with you something I discovered.

I was checking contests I took part in last year and stumbled into round 308 Div2. Problem D: This

This problem could be solved by simple O(n^3) by just picking all triplets and see if they make a triangle.

Well last year I calculated m1 = (y[k] — y[j]) / (x[k] — x[j]) and calculated m2 = (y[j] — y[i]) / (x[j] — x[i]) as doubles and if (m1 == m2) then it's triangle.

Looking at the constraints n <= 2000 so this answer should pass in the problem's time limit which is 4 seconds. But I got TLE.

This year while checking my previous solution, I decided to just convert the equation like this:

=> m1 = m2

=> (y[k] — y[j]) / (x[k] — x[j]) = (y[j] — y[i]) / (x[j] — x[i])

=> (y[k] — y[j]) * (x[j] — x[i]) = (y[j] — y[i]) * (x[k] — x[j])

So now both l1 and l2 could be calculated as integers, I did this and AC. Wow.

Seems like double division in C++ takes time, while multiplication as integers is faster, that's why I got AC.

Previous (TLE) Submission: Submission 18887929

Current (AC) Submission: Submission 18887986 c++,
By AFN, history, 6 years ago,  trie,