It is hard to answer your question when the statement is not public.
But using my psychic power I guess that your question is how to know the remainder of an arbitrary long bit sequence modulo K = 1000000007
.
Assuming this is indeed the question, you could note your bit string as:
b_0 b_1 ... b_n
Its value is:
V = b_0*2^0 + b_1*2^1 + ... + b_n*2^n
Given the property of the modulo operation you have:
V % K = [ (b_0*2^0) % K + (b_1*2^1) % K + ... + (b_n*2^n) % K ] % K
For powers of two below K
the computation is easy. For the others, you should use the modulo properties again:
V*W % K = [ (v % K) * (W % K) ] % K
For instance:
2^(1000) % K = [ (2^10) % K * ... * (2^10) % K ] % K
\_______________ __________________/
\/
100 factors
Each modulo is easily computed and less than K
making it fit for a long long
.
Overall complexity will be O(n*log(n))
, because you do O(log(n))
operation to compute 2^n % K
, and you do this n
times.