Блог пользователя Vrutik_2809

Автор Vrutik_2809, история, 23 месяца назад, По-английски

I was solving this problem. Although my solution is correct, I got TLE due to Java. My solution can be found here. But when i submitted the same solution in C++, it got accepted.(check it out here)

Can someone please help me out how to resolve this issue?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The issue is simply just that java is slower than c++. Without using some advanced factoring methods like pollard-rho, it might be impossible to solve that problem with java.

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

There's another blog post about Java performance when solving this particular problem: https://codeforces.net/blog/entry/110593

You can also always go to https://codeforces.net/contest/1771/status and filter the accepted solutions by the used programming language. You will see that there are some successful Java submissions. So solving it using Java is not impossible in principle.

But yes, Java users are generally at a disadvantage because of their programming language choice. Consider this as an extra challenge or try switching to a different programming language. C++ was always extremely popular in competitive programming. Rust is steadily gaining users too. And there are some other good choices.