dtdong08's blog

By dtdong08, 6 months ago, In English

Today I am studying about the Miller–Rabin primality test (the deterministic version). After having learned enough theory, I started trying to solve this problem on Library Checker. However, regardless of how much I tried, I kept getting TLE if I implement binary modulo multiplication or WA if I implement modulo multiplication with long double. Can anyone please help me optimize my current code or give me some crazy tricks so I can AC this problem?

Btw, I am not allowed to use __int128 due to my teacher ~

Also, here is my code, it is slightly long (105 LOC) so I put it in a Spoiler
  • Vote: I like it
  • -1
  • Vote: I do not like it