Cod sursa(job #1291981)
Utilizator | Data | 13 decembrie 2014 15:41:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
long long n,p,i,x=1,m = 1999999973;
in>>n>>p;
for(i=0;i<=31;i++)
{ if((p>>i)&1)
x=x*n%m;
n=n*n%m;
}
out<<x;
in.close();
out.close();
return 0;
}