In the problem statement it is given than P/Q, where P and Q are coprime positive integers. You should compute P⋅Q−1 modulo 10^9+7, where Q−1 denotes the multiplicative inverse of Q modulo 10^9+7. But then how can for 1/5 the answer becomes 400000003. asked 08 Feb, 22:07

See this https://discuss.codechef.com/questions/145069/guessrtfeb19b
multiplicative inverse of 5 modulo $10^9+7$ is 400000003