I'm trying to solve this problem - https://codeforces.com/problemset/problem/711/E
I've already found and proved that the result is equal to: $$ 1 - \frac{2^n (2^n - 1) \cdots (2 ^ n - k + 1)}{2^{nk}}. $$ Now I need to compute it, and it's hard as $n$ and $k$ could both be as large as $10^{18}$. Computing $2^{nk}$ is easy. But I have a problem with this factorial. Result, of course, only need to be found modulo $10^6 + 3$.
EDIT:
Note that A and B must be coprime before their remainders modulo $10^6 + 3$ are taken.