Modulus operation with long longs

Revision en1, by Deanamic_Programming, 2017-08-13 17:17:47

Hello everyone.
On yesterday's contest I implemented a exponentiation function.

long long pow(long long n, long long k) {  
        n %= MOD;  
	if(k == 0) return 1;  
	if(k&1) return (n*(pow(n*n, k/2))%MOD)%MOD;  
	return pow(n*n, k/2) %MOD;  
}  

long long get(long long n) {  
	long long t = (n * pow(2, n-1));  
	t %= MOD;  
	return t;  
}  

Which for some reason it returning a double when the exponent is high enough.
Why could this be?

Tags modulus, long long, c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Deanamic_Programming 2017-08-13 17:17:47 582 Initial revision (published)