Modulus operation with long longs

Правка en1, от 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?

Теги modulus, long long, c++

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Deanamic_Programming 2017-08-13 17:17:47 582 Initial revision (published)