Cod sursa(job #1586555)
Utilizator | Data | 1 februarie 2016 13:21:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
#define C 1999999973
using namespace std;
int main() {
fstream f("lgput.in",ios::in);
fstream g("lgput.out",ios::out);
long long n,p,x=1;
cin >> n;
cin >> p;
while( p!=0 ) {
if ( p% 2 == 1) {
x = (x*n)%C;
p--;
}
n = (n*n)%C;
p = p/2;
}
cout << x;
return 0;
}