Cod sursa(job #149120)
Utilizator | Data | 5 martie 2008 12:45:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
using namespace std;
int main()
{
long long n, p, rez;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
cin >> n >> p;
rez = 1;
while (p)
{
if (p & 1)
{
rez = rez*n % 1999999973;
p--;
}
n = n*n % 1999999973;
p = p/2;
}
cout << rez;
return 0;
}