Cod sursa(job #2041951)
Utilizator | UNIBUCThrowTerror Spiromanii_Messi | Data | 17 octombrie 2017 21:46:10 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std ;
ifstream cin ("lgput.in") ;
ofstream cout ("lgput.out") ;
unsigned int p (unsigned int x, unsigned int y, unsigned int m) {
unsigned int ret = 1 ;
for (; y; y >>= 1) {
if (y & 1U) {
ret = 1LL * ret * x % m ;
}
x = 1LL * x * x % m ;
}
return ret ;
}
int main(int argc, char const *argv[])
{
unsigned int a, b ;
cin >> a >> b ;
cout << p (a, b, 1999999973U) ;
return 0;
}