Cod sursa(job #1168910)
Utilizator | Data | 9 aprilie 2014 21:27:36 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
//#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long x,n,p;
int main(){
fin >> x >> n;
fin.close();
p=1;
while(n)
{
if(n%2!=0)
{
p*=x;
p%=1999999973;
}
x*=x;
x%=1999999973;
n/=2;
}
fout << p<<"\n";
fout.close();
return 0;
}