Cod sursa(job #807350)
Utilizator | Data | 4 noiembrie 2012 17:06:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include<cstdlib>
#include<cstdio>
int putere(int &x,int &p)
{
int n=1;
while(p>0)
{
if(p%2==1)
{
n*=x;
p--;
}
x= x*x;
p/=2;
}
return n;
}
int main()
{
int x,p;
scanf("%d ",&x);
scanf("%d",&p);
printf("%d",putere(x,p)%1999999973);
system("pause");
return 0;
}