We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Graph Theory
- Alex vs Fedor
- Discussions
Alex vs Fedor
Alex vs Fedor
Sort by
recency
|
11 Discussions
|
Please Login in order to post a comment
Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Alex vs Fedor Problem Solution
Here is the solution of Alex vs Fedor Click Here
Here is problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-alex-vs-fedor-problem-solution.html
The time limit is very tight for Python. When calculating the determinant, there is a dilemma between accuracy and speed. One way to optimize is to solve an mod p solution for small values of p. (p=1000003, 1000033,1000037 for example) Then we use the Chinese Remainder Theorem to find the actual value. The correctness is given by the constraint (#spanning trees < 10^18). This method is much faster than using the fraction module or mod a prime > 10^18.
I was working a solution in Racket, but suddenly that language is no longer available?