Cod sursa(job #558231)
Utilizator | Data | 17 martie 2011 10:00:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long int n, px, modulo=1999999973;
int main()
{
long long int rez, x, rest, a;
fin>>x>>n;
a=x; px=x; rez=1;
while(n)
{
rest=n%2;
if (rest==1)
rez=(rez*a)%modulo;
a=(a*a)%modulo;
n/=2;
}
fout<<rez;
return 0;
}