Cod sursa(job #1803466)
Utilizator | Data | 11 noiembrie 2016 15:11:38 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream in ( "lgput.in" );
ofstream out ( "lgput.out" );
int main()
{
unsigned long long a, b, s = 1;
in>>a>>b;
while (b) {
if (b%2==0) {
b = b / 2;
a = ( a * a ) % 1999999973;
}
else {
b--;
s = ( s * a ) % 1999999973;
}
}
out<<s;
return 0;
}