Cod sursa(job #330845)
| Utilizator | Data | 11 iulie 2009 18:45:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 kb |
# include <stdio.h>
# include <math.h>
int x,y,rez,m=1999999973;
int xyz (int x,int y)
{
if (y==1)
return x%m;
if (y%2==0)
return pow(xyz (x,y/2)%m,2);
else
return (x*xyz(x,y-1))%m;
}
int main ()
{
freopen ("lgput.in","r",stdin);
freopen ("lgput.out","w",stdout);
scanf ("%i%i",&x,&y);
printf ("%i",xyz (x,y));
return 0;
}
