As we know 1000000007 is a large prime number. How can I find multiplication of two large numbers modulo 1000000007
For example if I want to find 78627765*67527574 m
Why don't you want to use 64-bit arithmetic for that ? Of course this only works if the operands being multplied do not exceed 32 bits each (but this can also be fixed). Consider:
typedef unsigned long long uint64;
uint64 m = 1000000007UL;
uint64 r = (uint64)a * (uint64)b;
r = r % m; // get the residue
One can also optimize it to avoid '%' which might be expensive:
double inv = 1.0 / 1000000007UL; // precompute inverse
uint64 r = (uint64)a * (uint64)b;
uint64 rf = (uint64)floor((double)a * (double)b * inv); // floor(a * b / m)
r = r - rf * m; // residue
Note that the second method may require some playing around with accuracy. You can also use 'long double' instead