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