Hashing 2 - Double Hash

If you don’t read this blog or solved Kattis - inversefactorial on your own, complete these two tasks at first. In our previous part, we take m=1000000009 in our solution. But if we take m=1000000011 or m=1000000125 what would happen? If you are using these/some random values and getting WA, you are on the right track. In our previous solution, we mapped every big value $p$ with some small value $H(p)$.
Read more →

Hashing 1 : Inverse Factorial - Kattis inversefactorial

$$f(n)=n!$$ Given a value $x$ , find $f^{-1}{(x)}$ [that is, such $n$ so that $f(n)=x$]. Constraints click to hide number of digit in $x$ is atmost $10^{6}$ Solution: At first, this problem seems too hard. Suppose, we have a bijective function $H(p)$ which return some small integer value for corresponding $p$. Hence, we can uniquely represent every $p$ by $H(p)$. How to make $H(p)$ click to hide $H(p) = p \text{ (mod $m$)}$ [for a choosen $m$]
Read more →