Cod sursa(job #1601926)
Utilizator | Data | 16 februarie 2016 12:55:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
using namespace std;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long r=1,x,p;
scanf("%d %d",&x,&p);
while(p>0)
if(p%2==0)
{
x=(x*x)%1999999973;
p=p/2;
} else
{
r=(r*x)%1999999973;
p=p-1;
}
printf("%d",r%1999999973);
return 0;
}