Cod sursa(job #1368011)
Utilizator | Data | 2 martie 2015 13:03:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <stdio.h>
#define mod 1999999973
long long n,p,pow=1;
int main()
{
FILE*f1,*f2;
f1=fopen("lgput.in","r");
f2=fopen("lgput.out","w");
fscanf(f1,"%lld%lld",&n,&p);
while(p)
if(p%2)
pow=pow*n,p--;
else
n*=n,p/=2;
fprintf(f2,"%lld",pow);
return 0;
}